gruntydatsun Posted December 26, 2011 Posted December 26, 2011 (edited) Hi All, This is my first try at storing an encrypted password locally. I'm using the UUID of the workstation in use as the key which means youneed to be on the workstation that the password was initially entered to proceed without having to enter the password again. I only use this at home so the physical security of the pc is pretty good. Any advice on how to make this safer is appreciated. Func _Manage_Password() Local $reset, $encrypted_password, $handle, $pwfile $pwfile = @ScriptDir & "pw.enc" $reset = msgbox(260,"PASSWORD RESET","Would you like to reset your password?",2) ;does user want to rest password if $reset = 6 OR FileExists($pwfile) = 0 Then ;if resetting pword or pword file doesn't exist $encrypted_password = _StringEncrypt(1,InputBox("Title","Prompt","","*"),_Get_UUID(),8) ;get pword and encrypt into a string, UUID as key $handle = FileOpen($pwfile,2) ;open file in overwrite write mode FileWrite($handle,$encrypted_password) ;write encrypted string into file FileClose($handle) ;close password file Else $encrypted_password = FileRead($pwfile) ;read in encrypted password from file FileClose($pwfile) ;close password file EndIf return $encrypted_password ;return the encrypted password EndFunc And you call it like this: $encrypted_password = _Manage_Password() ;retrieve ecrypted pw or set a new one $password = _StringEncrypt(0,$encrypted_password,_Get_UUID(),8) ;decrypt password And _Get_UUID() look like this: Func _Get_UUID() If @OSArch='x86' Then $reg='HKEY_LOCAL_MACHINE' Else $reg='HKEY_LOCAL_MACHINE64' EndIf return RegRead($reg & 'SOFTWAREMicrosoftCryptography', 'MachineGuid') EndFunc Edited December 26, 2011 by gruntydatsun
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