Sign in to follow this  
Followers 0
Arterie

En/Decrypt strings

6 posts in this topic

#1 ·  Posted (edited)

Maybe i dont see the forest for the trees.

Maybe you could take a look at this code.

The StringTrimLeft(....,16) comes from the fact, that the numbers 1-5 which are my random encrypting levels are always 16 digits long, on lvl 3.

#include <String.au3>
save(500,"Test","Money")
MsgBox("","",load("Test","Money"))

Func save($Value,$Player,$Section)
    $Level = Random(1,5)
    $temp = _StringEncrypt(1,$Level,"123456",3)
    IniWrite("tempdata.ini",$Section,$Player,$temp & _StringEncrypt(1,$Value,"123456",$Level))
    Return 1
EndFunc

Func load($Player,$Section)
    $String = IniRead("tempdata.ini",$Section,$Player,0)
    $TrimLen = StringLen($String) - 16
    
    $Level = _StringEncrypt(0,StringTrimRight($String,$TrimLen),"123456",3)
    
    $Value = _StringEncrypt(0,StringTrimLeft($String,16),"123456",$Level)
    ;$Value = Number($Value)
    Return $Value
EndFunc
Edited by Arterie

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Not terrible for a first timer. You have a general idea. If you are looking for some excellent examples from the real world, take a look at Crypto Suite.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Ok, thanks. But i still want this little script wokring..

Share this post


Link to post
Share on other sites

Ok, thanks. But i still want this little script wokring..

Did you ever check the value of Random()? It generates a 256 char len for me because of the decimal:

Instead of: Random(1,5)

Try: Random(1,5, 1)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Try this:

Encrypt(500, "TEST", "Money")
ConsoleWrite(Decrypt("TEST", "Money") & @CRLF)

Func Encrypt($Value, $Section, $Player)
    $Level = Random(1, 5, 1)
    $temp = _StringEncrypt(1, $Level, "123456", 3)
    $temp2 = _StringEncrypt(1, $Value, "123456", $Level)
    IniWrite("tempdata.ini", $Section, $Player, $temp2)
    IniWrite("tempdata.ini", $Section, $Player & "Level", $temp)
    Return 1
EndFunc   ;==>Encrypt

Func Decrypt($Section, $Player)
    $Level = _StringEncrypt(0, IniRead("tempdata.ini", $Section, $Player & "Level", ""), "123456", 3)
    $Value = _StringEncrypt(0, IniRead("tempdata.ini", $Section, $Player, ""), "123456", $Level)
    Return $Value
EndFunc

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Ok with

Random(1,5, 1)

it works fine now. Thank you!

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