Jump to content

_StringEncrypt problems


chalup
 Share

Recommended Posts

I've wrote the script that on one point should read the file containing one line of encrypted text and decrypt it. On my computer (and on about 40 other computers) everything works fine, but recently the guy from Japan tried my script and _StringEncrypt returned some gibberish.

We're currently trying to figure out what may be the cause, but so far without success. The only thing we've noticed is the difference in new line sign: CRLF on my computer, LF on his. But the decrypted string is EXACTLY the same (it's checked just before decrytpion). Have anyone reported similar problems with _StringEncrypt ?

Link to comment
Share on other sites

I've wrote the script that on one point should read the file containing one line of encrypted text and decrypt it. On my computer (and on about 40 other computers) everything works fine, but recently the guy from Japan tried my script and _StringEncrypt returned some gibberish.

We're currently trying to figure out what may be the cause, but so far without success. The only thing we've noticed is the difference in new line sign: CRLF on my computer, LF on his. But the decrypted string is EXACTLY the same (it's checked just before decrytpion). Have anyone reported similar problems with _StringEncrypt ?

Create a short demo script that you can actually post on this forum (substitute fake data and passwords, of course), and which you tested to show your symptom of running on your machines, but not on the Japanese one. Without some code to look at, we can't do much for you.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create a short demo script that you can actually post on this forum

Here's the encrypted file creator:

#include <string.au3>

$var1 = "foobar"
$var2 = "blahblahblah"
$encstring1 = "dasdqwqwdobh8r9tjo8fj98g3j349f8gh"
$encstring2 = "k9rkv90m3tn;smchef90etjc47tjy7jg7"

$part2 = _StringEncrypt ( 1, $var2 , $encstring2 , 3 )
$tmpstring = $var1 & "," & $part2 
$whole = _StringEncrypt ( 1, $tmpstring , $encstring1 , 3 )

$file = FileOpen ( "output.txt", 2 )
FileWriteLine ( $file, $whole )
FileClose ( $file )

MsgBox ( 0, "ENCRYPTION TEST" , "DONE!" )

It created this file on my computer:

FDF08A....lots of hex data ....D85A8CA6

And here's file decryptor:

#include <string.au3>

Local $encstring1 = "dasdqwqwdobh8r9tjo8fj98g3j349f8gh"
Local $encstring2 = "k9rkv90m3tn;smchef90etjc47tjy7jg7"

Local $inputfile = "output.txt"
Local $encrypted 
Local $tmpstring
Local $split
Local $output

Local $file = FileOpen ( $inputfile , 0 )
$encrypted = FileReadLine ( $file )
FileClose ( $file )

While ( Asc ( StringRight ( $encrypted , 1 ) ) == 13 )
    Debug ( "Removing 0x0D character" )
    $encrypted = StringLeft ( $encrypted, StringLen($encrypted) - 1 )
WEnd

Debug ( "Input (" & StringLen ($encrypted) & " characters):" )
Debug ( $encrypted )
Debug ( "==============================" )

$tmpstring = _StringEncrypt ( 0, $encrypted , $encstring1 , 3 )
If ( @error == 1 ) Then
    Return 0
EndIf

Debug ( "First decrytpion successful:" )
Debug ( $tmpstring )
Debug ( "==============================" )

$split = StringSplit ( $tmpstring , "," )

If ( $split[0] <> 2 ) Then
    Return 0
EndIf

$output = _StringEncrypt ( 0, $split[2] , $encstring2 , 3 )
If ( @error == 1 ) Then
    Return 0
EndIf

Debug ( "Second decrytpion successful:" )
Debug ( $output )
Debug ( "==============================" )

MsgBox ( 0, "DECRYPTION TEST" , "DONE!" )

Func Debug ( $msg )
    Local $debuglog = FileOpen ("debug.log", 1)
    FileWriteLine ( $debuglog, $msg )
    FileClose ( $debuglog )
EndFunc

Here's decryptor output created on my computer:

Input (3184 characters):
FDF08A....lots of hex data ....D85A8CA6
==============================
First decrytpion successful:
foobar,49C209AB2A6D2C1A232F67677FFFD29428460F44AFF5A8A2843A16E4B857EC66EF2606FAA17D0255969E989AB7C30

6B3D45E0CEF68D0BB5863A8737D258D4714544698E0F61290F9B45BBF34BB9F93D4ECB61497A6B17AF5D026098B72F05879
==============================
Second decrytpion successful:
blahblahblah
==============================

I sent output.txt created on my computer and compiled decryptor to the japanese guy. Here's the debug.log created by decryptor on his computer:

Input (3184 characters):
FDF08A....lots of hex data ....D85A8CA6
==============================
First decrytpion successful:
f´ĚL%'NT.tÍąŢ4LËşČŘ:
==============================

Same input, same program, different result. I suppose it has something to do with different way of coding characters in Japanese version of OS. I'll probably have to do some _StringEncrypt modifications (of course if original author is fine with that's, although that shouldn't be a problem), but i thought that maybe this problem was already reported by someone and there is a fix available.

Link to comment
Share on other sites

By default, your FileOpen for write will be in ANSI mode, and that is surely not what the Japanese machine is using. Making the mode 2+32 or 2+64 will give you UTF16 formats to try. Should still work fine on this end because AutoIt autodetects the encoding on FileOpen for read. But maybe something about that doesn't work for ANSI on Windows with Japanese language default.

I'm just guessing here, but it's worth a try. The only thing you have to change is the mode when you FileOpen for write.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

By default, your FileOpen for write will be in ANSI mode, and that is surely not what the Japanese machine is using. Making the mode 2+32 or 2+64 will give you UTF16 formats to try. Should still work fine on this end because AutoIt autodetects the encoding on FileOpen for read. But maybe something about that doesn't work for ANSI on Windows with Japanese language default.

I'm just guessing here, but it's worth a try. The only thing you have to change is the mode when you FileOpen for write.

:)

Maybe i'm missing something, but take a look at those lines from the debug.log i got from him:

Input (3184 characters):
FDF08A....lots of hex data ....D85A8CA6

It means that the file was read correctly and the input data should be in $encrypted variable.

Edit:

brainfart.

debug.log is written also in ANSI, so i see that everything is fine, but it's still rubbish on his computer.

am i right?

Edited by chalup
Link to comment
Share on other sites

Edit:

brainfart.

debug.log is written also in ANSI, so i see that everything is fine, but it's still rubbish on his computer.

am i right?

That's the theory. But I don't have a Japanese language setup to test against. You'll have to tell me.

It would be good if others could try it on other setups where English is not the primary installed language, too. (Hint, hint...)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...