Sign in to follow this  
Followers 0
anixon

Encryption

2 posts in this topic

I have inserted two pieces of code which essentially perform the same task. The code that reads encrypted data stored in an INI files fails

a test which contains both equal to "=" and not equal to "<>".

The same test works without any problems when the data stored in the INI file is not encrypted.

Why is it so?

Help is always appreciated

Ant..

CODE
;Routine with encryption

;

$status = (_StringEncrypt(1, "0", "encryptionkey", 1))

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $le_status)

$address = (_StringEncrypt(1, "<no address recorded>", "encryptionkey", 1))

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section2", "value8", $l_email)

Global $key0 = (_StringEncrypt(1, "0", "encryptionkey", 1))

Global $key1 = (_StringEncrypt(1, "1", "encryptionkey", 1))

Global $rstatus = (_StringEncrypt(0, Iniread(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "1"), "encryptionkey", 1))

Global $raddress = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\my.ini", "section2", "value8", "Not Known"), "encryptionkey", 1))

If $rstatus = 0 and $raddress <> "<no address recorded>" Then ;Fails this test

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $key1)

Elseif $rstatus = 0 and $raddress = "<no address recorded>" Then

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $key0)

Else

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $key0)

EndIf

;Routine without encryption

;

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "0")

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section2", "value8", "<no address recorded>")

Global $lrstatus = Iniread(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "1")

Global $raddress = IniRead(@scriptdir&"\inifiles\my.ini", "section2", "value8", "Not Known")

If $rstatus = 0 and $raddress <> "<no address recorded>" Then ;Does not fail this test

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "1")

Elseif $rstatus = 0 and $raddress = "<no address recorded>" Then

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "0")

Else

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "0")

EndIf

Share this post


Link to post
Share on other sites



I have inserted two pieces of code which essentially perform the same task. The code that reads encrypted data stored in an INI files fails

a test which contains both equal to "=" and not equal to "<>".

The same test works without any problems when the data stored in the INI file is not encrypted.

Why is it so?

Help is always appreciated

Ant..

CODE
;Routine with encryption

;

$status = (_StringEncrypt(1, "0", "encryptionkey", 1))

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $le_status)

$address = (_StringEncrypt(1, "<no address recorded>", "encryptionkey", 1))

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section2", "value8", $l_email)

Global $key0 = (_StringEncrypt(1, "0", "encryptionkey", 1))

Global $key1 = (_StringEncrypt(1, "1", "encryptionkey", 1))

Global $rstatus = (_StringEncrypt(0, Iniread(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "1"), "encryptionkey", 1))

Global $raddress = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\my.ini", "section2", "value8", "Not Known"), "encryptionkey", 1))

If $rstatus = 0 and $raddress <> "<no address recorded>" Then ;Fails this test

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $key1)

Elseif $rstatus = 0 and $raddress = "<no address recorded>" Then

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $key0)

Else

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", $key0)

EndIf

;Routine without encryption

;

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "0")

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section2", "value8", "<no address recorded>")

Global $lrstatus = Iniread(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "1")

Global $raddress = IniRead(@scriptdir&"\inifiles\my.ini", "section2", "value8", "Not Known")

If $rstatus = 0 and $raddress <> "<no address recorded>" Then ;Does not fail this test

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "1")

Elseif $rstatus = 0 and $raddress = "<no address recorded>" Then

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "0")

Else

Iniwrite(@ScriptDir&"\inifiles\my.ini", "section1", "value1", "0")

EndIf

Have to fess up to this one. There is actually no issue with the encryption code it works just fine. What I found was in my origional code (similar to what I published here) the <no address recorded> in the "IF" Statement did not contain a leading and trailing space between "<" and ">". Given the literal nature of IF statements and becuase I was testing for "<no address recorded>" where it should have been "< no address recorded >" it did not match so it failed the test.

Cheers Ant..

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  
Followers 0