AutoHotkey Community

It is currently May 27th, 2012, 1:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: March 15th, 2010, 10:14 pm 
Offline

Joined: January 2nd, 2010, 6:13 pm
Posts: 105
Besides being more secure, a major advantage of TEA is that it does not increase the string length. The major disadvantage however, as I have mentioned before, is that it's output may not be easily usable as an AHK string.

To make its output usable as an AHK string, we may convert the result to Base64 which does not double the size of the result but nevertheless increases it. I discovered, however, that flipping (performing bitwise inversion) the output like Edxor (Format -> Flip) would result in an AHK usable string without increasing the string size.

Here's a script which demonstrates the flipping function I wrote for this purpose:
Code:
; Flip (bitwise invert) any text string like Edxor

exampleText := "The text here will be flipped as if with Edxor.`n`nFlipped texts should be easily usable as AHK strings, i.e. no quote characters, no accent, no backslash and no space characters in the beginning or end of flipped string.`n`nThis is OK only for mild, non-serious obfuscation of plain text. For real encryption use TEA function. However, TEA may output a string which may not be usable as an AHK string. Flipping it makes it usable without increasing the string size."

Gui, Margin, 2, 2
Gui, Add, Edit, w500 h300 vText2Flip, %exampleText%
Gui, Font, bold
Gui, Add, Button, wp y+5 gFlipData, F L I P       S T R I N G

Gui, Show,, Flip text like Edxor
Return

GuiEscape:
GuiClose:
ExitApp

FlipData:
   Gui, Submit, NoHide
   GuiControl,, Text2Flip, % flip(Text2Flip)
Return


flip(string)
{
   flippedString =
   Loop, parse, string
   {
     curCharAscii := Asc(A_LoopField)   ; get the ascii value of current character
    
     ; get the binary equivalent of this ascii value   ; Thanks to Laszlo for the method
     VarSetCapacity(curCharBinary, 65, 0)
     DllCall("msvcrt\_i64toa", Int64, curCharAscii, Str, curCharBinary, Int, 2)
    
     ; ensure that curCharBinary contains 8 chars, use 0 padding on left if necessary
     curCharBinary := SubStr("00000000" . curCharBinary, -7)   ; see help for SetFormat
    
     ; invert each binary digit in curCharBinary
     curCharBinaryInverted =
     Loop, parse, curCharBinary
       curCharBinaryInverted .= A_LoopField = 0 ? 1 : 0
    
     ; now convert this inverted binary number to decimal   ; Thanks to Laszlo for the method
     invertedDecimal := DllCall("msvcrt\_strtoui64", Str, curCharBinaryInverted, Uint, 0, Int, 2, "CDECL Int64")
    
     ; now get ascii char of this (inverted) decimal number
     invertedAscii := Chr(invertedDecimal)
    
     ;MsgBox, %A_LoopField%   %curCharAscii%   %curCharBinary%   %curCharBinaryInverted%   %invertedDecimal%   %invertedAscii%
      
     flippedString .= invertedAscii
   }
   Return, %flippedString%
}


EDIT: Thanks to Laszlo and Leef_me, the above code may be shortened to -
Code:
; Flip (bitwise invert) any text string like Edxor

exampleText := "The text here will be flipped as if with Edxor.`n`nFlipped texts should be easily usable as AHK strings, i.e. no quote characters, no accent, no backslash and no space characters in the beginning or end of flipped string.`n`nThis is OK only for mild, non-serious obfuscation of plain text. For real encryption use TEA function. However, TEA may output a string which may not be usable as an AHK string. Flipping it makes it usable without increasing the string size."

Gui, Margin, 2, 2
Gui, Add, Edit, w500 h300 vText2Flip, %exampleText%
Gui, Font, bold
Gui, Add, Button, wp y+5 gFlipData, F L I P       S T R I N G

Gui, Show,, Flip text like Edxor
Return

GuiEscape:
GuiClose:
ExitApp

FlipData:
   Gui, Submit, NoHide
   GuiControl,, Text2Flip, % flip(Text2Flip)
Return


flip(string)
{
   flippedString =
   Loop, parse, string
      flippedString .= Chr(0xff^Asc(A_LoopField))

   Return, %flippedString%
}


Last edited by arsan on March 19th, 2010, 6:52 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2010, 11:52 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I don't quite understand... If you want to flip the bits, just XOR with 0xFF..F (-1). But how does it help? When the data contains 0xFF, it will turn to 0x00, the string end marker.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2010, 4:27 am 
Offline

Joined: January 2nd, 2010, 6:13 pm
Posts: 105
Quote:
If you want to flip the bits, just XOR with 0xFF..F (-1)
I don't understand. All I know at present about XOR is that [0 xor 0 = 0, 1 xor 1 = 0, 0 xor 1 = 1, 0 xor 1 = 1]. I found some info here but need to read more. I don't know yet about xor with -1 but I'll look it up. Any pointers will be appreciated. The Transform command in AHK includes BitXor but I need to learn more to understand it.
Quote:
When the data contains 0xFF, it will turn to 0x00, the string end marker.
I'll think some more about it but it seems that flipping results in an ahk usable string only for regular text and not TEA encrypted text (if it contains 0xFF). I don't understand TEA. How likely is this character 0xFF likely to occur in TEA output. I've tested quite a few strings but the reverse decrypted text has always matched the input text up till now. All this encryption stuff is very new to me.

I've been using Edxorfor quite a while. It's written in assembly and is a great example of quality free software. So, learning about one way of obfuscation (flipping) was a thrill in itself. Besides, there are two standalone implementations of this flip function at page http://members.ozemail.com.au/~nulifetv/freezip/freeware/ written in assembly by the same author. In this page look for "DS File Ops Kit".

EDIT: I'm OK with xor now and have changed the flip program to xor based. It's much shorter now.


Last edited by arsan on March 19th, 2010, 11:01 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 7:23 am 
Offline

Joined: January 2nd, 2010, 6:13 pm
Posts: 105
Using the following script, I tested and found that out of characters with ascii codes ranging from 0 to 255, only the character with ascii code 255 (hex 0xff) is not flipped back properly:
Code:
; generate ascii table

; decimal > asciiChar > flippedAsciiChar > flippedBack2AsciiChar
; compare ascii character to flippedBack2Ascii character
#NoEnv
#SingleInstance, ignore

decimalValue = 0
output =
While, decimalValue <= 255
{
   char := Chr(decimalValue)
   
   flippedChar := flip(char)
   flippedDec := Asc(flippedChar)
   
   flippedBackChar := flip(flippedChar)
   
   If (char = flippedBackChar)
      testCheck = OK
   Else
   {
      testCheck = Failed
      MsgBox, %decimalValue%  %char% flip mismatch.
   }
      
   output .= decimalValue . "`t" . char . "`t" . flippedChar . "`t" . flippedBackChar . "`t" . flippedDec . "`t" . testCheck . "`n"
   
   decimalValue++
}

; Examine the output file manually
FileAppend, %output%, ascii.txt

flip(string)
{
   flippedString =
   Loop, parse, string
      flippedString .= Chr(0xff^Asc(A_LoopField))
      
   Return, %flippedString%
}

In English text, we usually use characters with ascii codes in the range 32 to 127, plus 13 for carriage return. We may additionally use many other characters but I don't know of any instance where the character with ascii code 255 (hex 0xff) may be used. So, flipping and flipping back any English text won't result in any data loss.

However, if we flip text encrypted with xTEA, we may lose data if the encrypted text contains character with ascii code 255 (hex 0xff). Since I don't understand yet the xTEA algorithm, I'd like to ask how much this character is likely to appear in xTEA encrypted text.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 5:55 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Dependent on your application some of the characters will not show or cause funny formatting changes. The script below prints the shorthands of the characters MsgBox has trouble with in my Win7 PC.
Code:
Loop 127
   t .= (A_Index "`t" Char(A_Index) "`t" Char(A_Index ^ 127)) . (mod(A_Index,3) ? "`t`t" : "`n")
MsgBox %t%

Char(n) {
   Return n=0 ? "NUL" : n=1 ? "SOH" : n=2 ? "STX" : n=8 ? "BS" : n=9 ? "HT" : n=10 ? "LF" : n=11 ? "VT"
       : n=12 ? "FF" : n=13 ? "CR" : n=28 ? "FS" : n=29 ? "GS" : n=30 ? "RS" : n=31 ? "US" : Chr(n)
}


Still, XOR is not a real cipher. Just looking at the most often occurring characters in your ciphertext reveals the algorithm.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 11:22 pm 
Offline

Joined: January 2nd, 2010, 6:13 pm
Posts: 105
Laszlo wrote:
... Still, XOR is not a real cipher. Just looking at the most often occurring characters in your ciphertext reveals the algorithm.

Of course. I understand that totally. The motive of flipping (bitwise inverting) text was not encryption but to create strings usable as ahk-strings. What I had in mind was that the text will be first encrypted using xTEA. Since the cipher text may contain " ' ` % or space characters, I wanted to flip them hoping that it would result in text usable as ahk-strings.

I even posted a separate request topic regarding this at http://www.autohotkey.com/forum/viewtopic.php?t=55832

Thanks for the clarification Laszlo.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2010, 3:54 am 
Offline

Joined: November 16th, 2007, 2:17 am
Posts: 231
Laszlo wrote:
The key consists of five 32-bit numbers, stored in the variables k1...k5. If you have a text password you have to convert it to 5 numbers.

InputBox pwd, PassPhrase, Enter your PassPhrase, HIDE, 400, 160
IfNotEqual ErrorLevel,0, ExitApp
PWD2Key(pwd, k1,k2,k3,k4,k5)


Hey Laszlo, quick question. What kind of parameters for the password here do you recommend that can be the most secure with the encryption program?

Certain number of characters for password length (up to 25)?
Would capitals and noncapitals make it stronger?
Symbols like: ?/.-+ make it stronger?

For example:
Weak password: pass
Strong password: -lJIjdlA93k90-&KP

Would the above be correct or it doesn't matter.

Thanks for the help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2010, 4:00 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Of course, if an adversary can guess your password, he can generate your encryption key, and read your secrets. There are many places for information about password strength, like http://en.wikipedia.org/wiki/Password_strength.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2010, 5:18 pm 
Offline

Joined: June 17th, 2008, 7:51 am
Posts: 243
I get a curious behavior with the TEA-Functions, when using AHKL and a long password.
Code:

;-------------------------------------------------------------------------------
;
; TEA Encryption Library 0.10
; String and File Encruption Library for AutoHotkey
;
; - Original Encryption Functions By Laszlo
; - Library Modifications by Danny Ben Shitrit (aka Icarus)
;
; - Forum: http://www.autohotkey.com/forum/viewtopic.php?p=27017#27017
;
; FUNCTIONS IN THIS LIBRARY:
;   EncryptFile( inputFile, password, outputFile="" ) ; rewrite to inputFile if
;   DecryptFile( inputFile, password, outputFile="" ) ; outputFile is empty.
;
;   NewString := EncryptString( inputString, password )
;   NewString := DecryptString( inputString, password )
;
; Revision History at the end of the file
;
;-------------------------------------------------------------------------------

; TESTER - Delete or comment out when including the file
;-------------------------------------------------------------------------------

; File Encryption / Decryption
;  EncryptFile( A_ScriptFullPath , "myNicePassword" , "encrypted.txt" )
;  DecryptFile( "encrypted.txt"  , "myNicePassword" , "decrypted.txt" )

; String Encryption / Decryption
MyString  := "Hello world, I am a nice readable string mit ö, ü,ä,ß" ; Encrypted := TEA_EncryptString( MyString , "aSimplePassword" )
 ; Decrypted := TEA_DecryptString( Encrypted, "aSimplePassword" )
Encrypted := TEA_EncryptString( MyString , "aüopjkoeiop<sekJKHIU34u9ß8s5zjhikmydrojilgoöyeuprj@akll€" )
 Decrypted := TEA_DecryptString( Encrypted, "aüopjkoeiop<sekJKHIU34u9ß8s5zjhikmydrojilgoöyeuprj@akll€" )
 Msgbox Original:`t`t[%MyString%]`nEncrypted:`t[%Encrypted%]`nDecrypted:`t[%Decrypted%]

;-------------------------------------------------------------------------------
; END OF TESTER


;-------------------------------------------------------------------------------
; INTERFACE
;-------------------------------------------------------------------------------
TEA_EncryptFile( inputFile, password, outputFile="" ) {
  ; Reads a file, encrypts its contents and write it back to itself or
  ; to a new file.
  ;_____________________________________________________________________________
  If( outputFile = "" )
    outputFile .= inputFile . ".enc"
   
  FileRead FileString, %inputFile%
  FileDelete %outputFile%
  FileAppend % TEA_EncryptString( FileString, password ), %outputFile%
}

TEA_DecryptFile( inputFile, password, outputFile="" ) {
  ; Reads a file, decrypts its contents and write it back to itself or
  ; to a new file.
  ;_____________________________________________________________________________
  If( outputFile = "" )
    outputFile .= inputFile . ".dec"
   
  FileRead FileString, %inputFile%
  FileDelete %outputFile%
  FileAppend % TEA_DecryptString( FileString, password ), %outputFile%
}


TEA_EncryptFileLine( inputFile, password, outputFile="" ) {
  ; Reads a file line-by-line, encrypts its contents and write it back to itself or
  ; to a new file.
  ;_____________________________________________________________________________
  If( outputFile = "" )
    outputFile := inputFile . ".enc"
   
  FileDelete %outputFile%
   Loop, Read, %InputFile%, %outputFile%
   {
      FileAppend % TEA_EncryptString( A_LoopReadLine , password ) . "`r`n"
      ; ToolTip,%A_Index%,400,1
   }
}

TEA_DecryptFileLine( inputFile, password, outputFile="" ) {
  ; Reads a file line-by-line, decrypts its contents and write it back to itself or
  ; to a new file.
  ;_____________________________________________________________________________
  If( outputFile = "" )
    outputFile := inputFile . ".dec"
   
  FileDelete %outputFile%
   Loop, Read, %InputFile%, %outputFile%
   {
      FileAppend % TEA_DecryptString( A_LoopReadLine , password ) . "`r`n"
      ToolTip,%A_Index%,400,1
   }
}


TEA_EncryptString( inputString, password ) {
  ; Gets a plain string and returns the encrypted string.
  ;_____________________________________________________________________________
   TEA_Pwd2Key( password, k1,k2,k3,k4,k5 )
 
  i := 9                         ; pad-index, force restart
  p := 0                         ; counter to be encrypted
  OutString := ""
 
  Loop Parse, inputString, `n,`r
  {
    ThisLine := A_LoopField
    L := ""                      ; processed line
    Loop % StrLen( ThisLine )
    {
      i++
      IfGreater i,8, {        ; all 9 pad values exhausted
        u := p
        v := k5              ; another secret
        p++                  ; increment counter
        TEA_TEA(u,v, k1,k2,k3,k4)
        TEA_Stream9(u,v)         ; 9 pads from encrypted counter
        i = 0
      }
      StringMid c, ThisLine, A_Index, 1
      a := Asc(c)
      if a between 32 and 126
      {                       ; chars > 126 or < 31 unchanged
        a += s%i%
        IfGreater a, 126, SetEnv, a, % a-95
        c := Chr(a)
      }
      L := L . c              ; attach encrypted character
    }
    OutString .= L . "`n"
  }
  StringTrimRight OutString, OutString, 1
  Return OutString
}

TEA_DecryptString( inputString, password ) {
  ; Gets an encrypted string and returns the plain string.
  ;_____________________________________________________________________________
  TEA_Pwd2Key( password, k1,k2,k3,k4,k5 )
 
  i := 9                         ; pad-index, force restart
  p := 0                         ; counter to be encrypted
  OutString := ""
 
  Loop Parse, inputString, `n,`r
  {
    ThisLine := A_LoopField
    L := ""                    ; processed line
    Loop % StrLen( ThisLine )
    {
      i++
      IfGreater i,8, {        ; all 9 pad values exhausted
        u := p
        v := k5              ; another secret
        p++                  ; increment counter
        TEA_TEA(u,v, k1,k2,k3,k4)
        TEA_Stream9(u,v)         ; 9 pads from encrypted counter
        i = 0
      }
      StringMid c, ThisLine, A_Index, 1
      a := Asc(c)
      if a between 32 and 126
      {                       ; chars > 126 or < 31 unchanged
        a -= s%i%
        IfLess a, 32, SetEnv, a, % a+95
        c := Chr(a)
      }
      L := L . c              ; attach encrypted character
    }
    OutString .= "`n" . L
  }
  Return SubStr(OutString,2)
}

;-------------------------------------------------------------------------------
; INTERNAL ENCRYPTION FUNCTIONS
;-------------------------------------------------------------------------------

TEA_PWD2Key(PW, ByRef k1, ByRef k2, ByRef k3, ByRef k4, ByRef k5) {
  TEA_CBC(k1,k2, PW, 1,2,3,4)
  TEA_CBC(k3,k4, PW, 4,3,2,1)
  k5 := k1^k2^k3^k4
}

TEA_CBC(ByRef u, ByRef v, x, k0,k1,k2,k3) {
  u = 0
  v = 0
  Loop % Ceil(StrLen(x)/8)
  {
    p = 0
    StringLeft  c, x, 4
    Loop Parse, c
      p := (p<<8) + Asc(A_LoopField)
    u := u ^ p
    p = 0
    StringMid   c, x, 5, 4
    Loop Parse, c
      p := (p<<8) + Asc(A_LoopField)
    v := v ^ p
    TEA_TEA(u,v,k0,k1,k2,k3)
    StringTrimLeft x, x, 8
  }
}


TEA_TEA(ByRef y,ByRef z,k0,k1,k2,k3) { ; (y,z) = 64-bit I/0 block
                                   ; (k0,k1,k2,k3) = 128-bit key
  IntFormat = %A_FormatInteger%
  SetFormat Integer, D          ; needed for decimal indices
  s := 0
  d := 0x9E3779B9
  Loop 32
  {
    k := "k" . s & 3           ; indexing the key
    y := 0xFFFFFFFF & (y + ((z << 4 ^ z >> 5) + z  ^  s + %k%))
    s := 0xFFFFFFFF & (s + d)  ; simulate 32 bit operations
    k := "k" . s >> 11 & 3
    z := 0xFFFFFFFF & (z + ((y << 4 ^ y >> 5) + y  ^  s + %k%))
  }
  SetFormat Integer, %IntFormat%
  y += 0
  z += 0                        ; Convert to original ineger format
}

TEA_Stream9(x,y) {                     ; Convert 2 32-bit words to 9 pad values
                               ; 0 <= s0, s1, ... s8 <= 94
  Local z                       ; makes all s%i% global
  s0 := Floor(x*0.000000022118911147) ; 95/2**32
  Loop 8
  {
    z := (y << 25) + (x >> 7) & 0xFFFFFFFF
    y := (x << 25) + (y >> 7) & 0xFFFFFFFF
    x  = %z%
    s%A_Index% := Floor(x*0.000000022118911147)
  }
}

The code is utf-8 and compiled with the latest version of Lexikos' AutoHotkeySC.bin. The misterious: when running as script, the code produces the same encrypted string as in AHK basic. When running compiled, it produces a totally different string, which is bad for testing and which is worse with old AHKbasic-encrypted files, that can't get decrypted by the AHK_L-exe.

Edit: It was my fault, because I got lost between the different versions of AHK.exe and AHKSC.bin. But I still have the problem, that I get different results witk AHKbasic and AHK_L, so that the already existing keyfiles don't match any longer.
Quote:
---------------------------
TEA.ahkl
---------------------------
Original: [Hello world, I am a nice readable string mit ö, ü,ä,ß]
Encrypted: [9Gr+P$KjqC_zh.UB<UD #n>ide/Gj[.>X,MKoIv\wehILö>1ücä%ß]
Decrypted: [Hello world, I am a nice readable string mit ö, ü,ä,ß]
---------------------------
OK
---------------------------
Quote:
---------------------------
TEA.ahk
---------------------------
Original: [Hello world, I am a nice readable string mit ö, ü,ä,ß]
Encrypted: [w\7M)rrE@ }#d^TbJe.KuPHT$R8m-_n*%#(i*9bhkBJ*?önhü_ätß]
Decrypted: [Hello world, I am a nice readable string mit ö, ü,ä,ß]
---------------------------
OK
---------------------------

_________________
Greetings
Rog


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2010, 10:44 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
The character "€" is 8364 in Unicode and 128 in ANSI (on my system). If you remove that character, you should get consistent results. (Also see my response here.) You may use the following as reference:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 20th, 2010, 9:59 pm 
Offline

Joined: June 17th, 2008, 7:51 am
Posts: 243
Thanks Lexikos, I will try. It seems, that I unfortunately used some wrong characters for the passwords. But this helps me very much to know, which characters not to use.

_________________
Greetings
Rog


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2011, 11:16 am 
Found this code other day (sorry, can't say where it belongs to) and quick tested it, found it perfect:

Code:
;....GUI by Eedis
Gui, Font, S7 Bold, Tahoma
Gui, Color, CCDCDC0
Gui, Add, Text,     x6    y6 w250 h22, Enter the Seed to encode:
Gui, Add, Text,     x278  y6 w250 h22, Enter the Seed to decode:
Gui, Add, Edit, vek x176  y6 w70 h22, default
Gui, Add, Edit, vdk x450  y6 w70 h22, default
;..
Gui, Add, Edit, vmte x6   y36 w250 h140,
Gui, Add, Edit, vcte x276 y36 w250 h140, 5ntMot53FomedG.De5,4.kA5s-4Vje;8QoNDA5q Cgp7xKPtlPcjCV&q&m8,i:9I!j5XttN|
Gui, Font, S10 Bold, Tahoma
Gui, Add, Text, x6   y196 w180 h22 cRed, ENCRYPTION
Gui, Add, Text, x276 y196 w180 h22 cBlue, DECRYPTION
;..
Gui, Add, Edit, vme ReadOnly x6   y224 w250 h140,
Gui, Add, Edit, vce ReadOnly x276 y224 w250 h140,
;..
Gui, Add, Button, gEncrypt x6   y366 w160 h36, Run..Encrypt
Gui, Add, Button, gDecrypt x276 y366 w160 h36, Run..Decrypt
Gui, Add, Button, gReload  x458 y366 w80 h36,  Reload
Gui, Show, w532 h400, Encrypt/Decrypt
Return

Encrypt:
Gui, Submit, Nohide
me:=CodeG(mte,1,ek)
GuiControl,, me, %me%
Return

Decrypt:
Gui, Submit, Nohide
GuiControl,, ce, % CodeG(cte,-1,dk)
Return

Reload:
Reload

GuiClose:
ExitApp

CodeG(x,E,K1=0,K2=1,K3=2,K4=3) { ; x: data string, E=1|-1: encode|decode, K1..4: 32 bit unsigned keys
   Static
   If (C1!=K1 || C2!=K2 || C3!=K3 || C4!=K4) {
      L := 224, C1 := K1 , C2 := K2 , C3 := K3 , C4 := K4
      Loop %L%
         D%A_Index% := 0, S .= Chr(A_Index+31)
      Loop 4 {
         Random,,K%A_Index%
         Loop %L% {
            Random D, 0, L-1
            D%A_Index% := mod(D+D%A_Index%,L)
         }
      }
   }
   C =
   Loop Parse, x
      C .= " "<=(A:=A_LoopField) ? SubStr(S,mod(InStr(S,A,1)+L-1+E*D%A_Index%,L)+1,1) : A
   Return C
}

But when running it for real I noticed it places "ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ" after a small chunk of well-done encryption.
Can someone please fix it, or expand/remove such limitation?
TIA.[/quote]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2011, 6:52 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
The original function is here, but you use it incorrectly: with only one key out of the 4 required, which is not secure. Also, the 4 keys should be 32 bit unsigned integers, not text strings, as your default values are. Also, the note at the original post tells you that "Be careful with the ciphertext. Dependent on your application where you handle them, some funny characters may be dropped, others may be changed, altering the corresponding character at decryption." The ciphertext is not safe to be put in a GUI control.

If you need to debug the problem, please post the 4 keys, the input and the output, which cause the problem.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2011, 8:37 pm 
Thanks for the heads up, Laszlo.

Code:
The game is installed to the following path:

Vista & Win 7: C;\Program Files(x86)\World Voyage

Win XP: C\Program files\World Voyage

Shortcuts are installed to the desktop and th Start menu program folder where you’ll also find an uninstaller. The installed game is 79.9Mb

Introduction:

Ever dreamed of a voyage round the world? Discover the amazing beauty of the world’s most famous sights with a new original game. World Voyage will become your travel encyclopedia, awarding you with wonderful pictures of the world’s most famous places every 5 levels! Apart from this, you will learn a lot of valuable information. Spend your time with pleasure and to your benefit!

Seed: "default" or "1234", result is the same:

[code]
Z­½È`‘‚#ÃÔ&†g'ª2‰†r·¤®âô« 0¤tgy§YC¹5+¶


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2011, 9:44 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
The used cipher was meant for very short messages (<225 characters). I forgot to document this restriction at the original post (now fixed). For general case use the other function in the same place.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group