Jump to content
Sign in to follow this  

Unicode or code page problem ?

Recommended Posts


I have a problem with a friend of my who live in china and reported me that one of my script does'nt work. I identified where is the problem but i don't understand what happen and more important how to avoid this.

I use the following code found on this forum:

Func Blowfish($key, $message, $decrypt=1)
    Local $i, $m, $len = StringLen($message)
    Local $xl, $xr, $result
    If IsDeclared("P") <> 1 Or IsDeclared("S") <> 1 Or IsDeclared("Gkey") <> 1 Then
        Global $P[18]
        Global $S[4][256]
        Global $Gkey = $key
        BlowFish_Init($P, $S, $Gkey)
    ElseIf Not ($Gkey == $key) Then
        Global $P[18]
        Global $S[4][256]
        Global $Gkey = $key
        BlowFish_Init($P, $S, $Gkey)
    While Mod(StringLen($message),8) <> 0
        $message &= Chr(0)

    While $m < $len
        $xl = StringMid($message,$m+1,4)
        $xr = StringMid($message,$m+5,4)
        $m += 8
        $xl = BitOR(BitShift(Asc(StringMid($xl,1,1)),-24),BitShift(Asc(StringMid($xl,2,1)),-16),BitShift(Asc(StringMid($xl,3,1)),-8),Asc(StringMid($xl,4,1)))
        $xr = BitOR(BitShift(Asc(StringMid($xr,1,1)),-24),BitShift(Asc(StringMid($xr,2,1)),-16),BitShift(Asc(StringMid($xr,3,1)),-8),Asc(StringMid($xr,4,1)))
        If $decrypt == 0 Then
            BlowFish_Encrypt($P, $S, $xl, $xr)
            BlowFish_Decrypt($P, $S, $xl, $xr)
        $result &= Chr(BitAND(BitShift($xl,24),0xFF))
        $result &= Chr(BitAND(BitShift($xl,16),0xFF))
        $result &= Chr(BitAND(BitShift($xl,8),0xFF))
        $result &= Chr(BitAND($xl,0xFF))
        $result &= Chr(BitAND(BitShift($xr,24),0xFF))
        $result &= Chr(BitAND(BitShift($xr,16),0xFF))
        $result &= Chr(BitAND(BitShift($xr,8),0xFF))
        $result &= Chr(BitAND($xr,0xFF))
; Strip Null Bytes from end of string (Are present if decrypting)
;$result = StringReplace($result,Chr(0),"")

    Return $result

We encrypt the same string using the same key but the result is different on his computer installed with XP chinese version (some characters miss) ???

Can someone explain this ?

Share this post

Link to post
Share on other sites

There is a unicode version of AutoIt if I remember correctly.

I'm using it.

Here is the console output:

>Running:(\Program Files\AutoIt3\aut2exe\aut2exe.exe
+>15:27:56 Aut2exe.exe ended.rc:0
->Warning: This is an Unicode compiled script and will not run on Win9x/ME.
+>15:27:57 RC.exe ended.rc:0
+>15:27:58 ResHacker ended.rc:0

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...