cherdeg Posted March 19, 2010 Share Posted March 19, 2010 Hello Pals,This is my code:#include <Crypt.au3> Global $s_IniFile = "test.ini" ;~ $s_RemoteUserPasswordHash = IniRead($s_IniFile, "General", "RemoteUserPasswordHash", "") ;~ Local $b_Encrypted = Binary("$s_RemoteUserPasswordHash") Local $b_Encrypted = Binary("0x4AFFF9D9ECC556D90AF00046") If $b_Encrypted <> "" Then _Crypt_Startup() $h_Key = _Crypt_DeriveKey("Arschloch-Karte17", $CALG_RC4) _Crypt_DestroyKey($h_Key) _Crypt_Shutdown() $s_RemotePassword = BinaryToString(_Crypt_DecryptData($b_Encrypted, $h_Key, $CALG_RC4)) Else ConsoleWrite(@CRLF & "No hash found in the INI-File!") EndIf MsgBox("", "Password", $s_RemotePassword)If only (!!!) this line:;~ $s_RemoteUserPasswordHash = IniRead($s_IniFile, "General", "RemoteUserPasswordHash", "")...is uncommented (nothing else!!!), the hash is not correctly decrypted to the correct value of "ValikIsAGirl", no matter if the inifile/key/value exist - and even although $s_RemoteUserPasswordHash isn't used further. Why?!?!?!?Me = totally clueless. Is this a Friday's problem trying to tell me to call it a day and go for the weekend?Regards,Chris Link to comment Share on other sites More sharing options...
BrettF Posted March 19, 2010 Share Posted March 19, 2010 ValikIsAGirlTreading on something can only be described as glass injected with AIDs. With some hot coals, used needles and feathers thrown in. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
cherdeg Posted March 19, 2010 Author Share Posted March 19, 2010 (edited) Treading on something can only be described as glass injected with AIDs. With some hot coals, used needles and feathers thrown in.Is Valik eventually not a girl? I don't know him/her personally, and "Valik" is neither male nor female. He/She always has Avatar pictures with girls...so? The passphrase was used completely unintentional and without any spirit of mischief. I didn't mean to tread on him/her. Now that that's cleared, do you have some advice regarding the problem? Edited March 19, 2010 by cherdeg Link to comment Share on other sites More sharing options...
monoceres Posted March 19, 2010 Share Posted March 19, 2010 Here's a shot in the dark. You have these two lines: _Crypt_DestroyKey($h_Key) _Crypt_Shutdown() Before the [url="../autoit3/docs/functions/BinaryToString.htm"]BinaryToString[/url](_Crypt_DecryptData($b_Encrypted, $h_Key, $CALG_RC4)) Which means that the key is no longer valid. Change the order and see if it solves the problem. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
JSThePatriot Posted March 19, 2010 Share Posted March 19, 2010 (edited) I will admit quickly, I know nothing of the functions you're using from the Crypt library as I haven't used any of them, but it would seem you're destroying the key too soon, and you're also shutting down the Crypt library before calling your last function. Maybe try the following? #include <Crypt.au3> Global $s_IniFile = "test.ini" ;~ $s_RemoteUserPasswordHash = IniRead($s_IniFile, "General", "RemoteUserPasswordHash", "") ;~ Local $b_Encrypted = Binary("$s_RemoteUserPasswordHash") Local $b_Encrypted = Binary("0x4AFFF9D9ECC556D90AF00046") If $b_Encrypted <> "" Then _Crypt_Startup() $h_Key = _Crypt_DeriveKey("Arschloch-Karte17", $CALG_RC4) $s_RemotePassword = BinaryToString(_Crypt_DecryptData($b_Encrypted, $h_Key, $CALG_RC4)) ; The below lines seemed to come to early because you were trying to use _Crypt_DecryptData() after ; shutting down the library. So this was a simple change. I hope it works out for you. _Crypt_DestroyKey($h_Key) _Crypt_Shutdown() Else ConsoleWrite(@CRLF & "No hash found in the INI-File!") EndIf MsgBox("", "Password", $s_RemotePassword) @monoceres Good job, you beat me to it! Thanks a ton, Jarvis Edited March 19, 2010 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
ProgAndy Posted March 19, 2010 Share Posted March 19, 2010 (edited) You do not have to use use CryptDeriveKey, just use the key-string directly in Decrypt, startup and shutdown is not required, too. Everything is done by _Crypt_DecryptData. #include <Crypt.au3> $sString = "a Teststring" $b_Encrypted = _Crypt_EncryptData(StringToBinary($sString), "Arschloch-Karte17", $CALG_RC4) MsgBox(0, '', $b_Encrypted) $s_RemotePassword = BinaryToString(_Crypt_DecryptData($b_Encrypted, "Arschloch-Karte17", $CALG_RC4)) MsgBox(0, '', $s_RemotePassword) Edited March 19, 2010 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
cherdeg Posted March 19, 2010 Author Share Posted March 19, 2010 (edited) Hey Guys, thank you all - everything you say may be correct. And indeed, _Crypt_DeriveKey, start and stop of encryption isn't needed. Now it works...but it's still a riddle for me that it didn't before... Encryption: #include <Crypt.au3> Local $s_IniFile = "test.ini" $s_Password = InputBox("Password Encrypter", "Please enter the password to encrypt: ") $s_Hash = _Crypt_EncryptData($s_Password, "Arschloch-Karte17", $CALG_RC4) ClipPut($s_Hash) IniWrite($s_IniFile, "General", "RemoteUserPasswordHash", $s_Hash) MsgBox("", "Password Encrypter", "Resulting hash: " & $s_Hash & @CRLF & @CRLF & _ "The INI-File was updated with the generated hash." & @CRLF & _ "Also the hash was copied to the clipboard.") Decryption: #include <Crypt.au3> Local $s_RemoteUserPasswordHash = IniRead("test.ini", "General", "RemoteUserPasswordHash", "") Local $b_Encrypted = Binary($s_RemoteUserPasswordHash) If $b_Encrypted <> "" Then $s_RemotePassword = BinaryToString(_Crypt_DecryptData($b_Encrypted, "Arschloch-Karte17", $CALG_RC4)) Else ConsoleWrite(@CRLF & "No hash found in the INI-File!") EndIf ClipPut($s_RemotePassword) MsgBox("", "Password Decrypter", "Resulting password: " & $s_RemotePassword & @CRLF & @CRLF & _ "The password was copied to the clipboard.") Thank you all and...have a great weekend!!! Regards, Chris Edited March 19, 2010 by cherdeg Link to comment Share on other sites More sharing options...
Valik Posted March 19, 2010 Share Posted March 19, 2010 (edited) The last time I checked, I had a penis. Maybe I need to go check again? At any rate, I don't always use female avatars. The previous avatar was Fruit Fucker, which is definitely male (as far as robots go). I've previously used an image of Homer Simpson's brain (male), Homer Simpson in drag (confused male) and BloodRayne (female).Edit: Also, the gender field is set on my account... so yeah. Edited March 19, 2010 by Valik Link to comment Share on other sites More sharing options...
cherdeg Posted March 20, 2010 Author Share Posted March 20, 2010 Edit: Also, the gender field is set on my account... so yeah.Then only left for me is desperate hope that you aren't pissed... Link to comment Share on other sites More sharing options...
Developers Jos Posted March 20, 2010 Developers Share Posted March 20, 2010 Then only left for me is desperate hope that you aren't pissed...He doesn't drink so that will not happen .... or did you mean something else? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nutster Posted March 22, 2010 Share Posted March 22, 2010 Is Valik eventually not a girl? I don't know him/her personally, and "Valik" is neither male nor female.It is pretty easy to determine that his name is Jason, which in my experience is usually male. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
cherdeg Posted March 22, 2010 Author Share Posted March 22, 2010 (edited) It is pretty easy to determine that his name is Jason, which in my experience is usually male.If you care, you care. If you don't, you don't. I was just randomly picking a phrase. Edited March 22, 2010 by cherdeg 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