CHronologist Posted July 16, 2008 Share Posted July 16, 2008 I wanted to create an improved OneTimePad function, especially for shorter strings like username and password combinations. So I added two features: 1) I didn't use the ASCII or UNICODE signs, but a pool inside the function. This results in less possibility to decrypt the code, because an attacker would exspect a relation between the signs based on the ASCII code, but since you can shuffle the order of the sign pool this is not given. 2) The order of the sign pool shifts while encrytping, in my code only by placing the last sign at the beginning, but you theoretically could use any other reversable algorithm and an attacker that doesn't know about it, won't find a way to decrypt. So it's like a second key to the code. #include <string.au3> Func OneTimePad($Text, $Key, $Flag = 1) Local $Encrypted = "", $Fullkey = "", $Tab = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $len $len = StringLen($Text) If $Flag <> 1 Then $Flag = -1 If $Flag = -1 Then For $i = 1 to $len + 1 $Tab = StringRight($Tab, StringLen($Tab) - 1) & StringLeft($Tab, 1) Next $Text = _StringReverse($Text) EndIf For $i = 1 to Int($len/StringLen($Key)) $Fullkey &= $Key Next $Fullkey &= StringLeft($Key, $len - StringLen($Fullkey)) For $i = 1 to $len If $Flag = 1 Then $Tab = StringRight($Tab, StringLen($Tab) - 1) & StringLeft($Tab, 1) Else $Tab = StringRight($Tab, 1) & StringLeft($Tab, StringLen($Tab) - 1) EndIf $Encrypted &= StringMid($Tab, Mod(StringInStr($Tab, StringMid($Text, $i, 1), 1) + $Flag * StringInStr($Tab, StringMid($Fullkey, $i, 1), 1) + 62, StringLen($Tab)), 1) Next If $Flag = -1 Then $Encrypted = _StringReverse($Encrypted) Return($Encrypted) EndFunc Please tell me what you think. If it is an improvement or total crap. If it could be more simple or if there is a case it doesn't work (of course I tested everything that came to my mind). Chronologist Link to comment Share on other sites More sharing options...
billthecreator Posted July 16, 2008 Share Posted July 16, 2008 Nothing happens when i try it. i even tried to call the function before it. nothing... am i supposed to do something? [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
billthecreator Posted July 16, 2008 Share Posted July 16, 2008 EDIT: actually if you put: MsgBox(0,"",OneTimePad("hello",10)) then it does spit something out... and in that case, i wont find any use in it, but i think someone will. [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
CHronologist Posted July 16, 2008 Author Share Posted July 16, 2008 (edited) For the use, it should serve you in protecting your data. You call the function with the text you want to encrypt and the key you want to use, to decrypt an encrypted text call the function with the encrypted text, the key that were used, and the third argument as -1 and you should get back the original text. @billthecreator, could you explain what you did when it didn't work, I can't figure out. Maybe you used a sign which is no in the sign pool like " ". Edited July 17, 2008 by CHronologist Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now