Swimming_Bird Posted July 20, 2006 Share Posted July 20, 2006 I'd like to generate a 12 character encrypted string that would always be 12 char and would always be uneque based on the password and keyword given. The problem with _StringEncrypt is that the lenght is based on the keyword so longer keywords would generate massive codes. Link to comment Share on other sites More sharing options...
evilertoaster Posted July 20, 2006 Share Posted July 20, 2006 It's up to you to implement a propitary encryption method...You can really do anythign you want! For instance- MsgBox(0,"Encrypted string",CryptString("Hello World")) Func CryptString($string) $Return="" for $a=1 to StringLen($string) $Return&=Chr(Asc(StringMid($string,$a,1))+1) Next Return $Return EndFunc That's just basic encryption. you can mess around with it however you wish or use an existing method that suits your needs...but don't expect someone to write you a custom encryption routine from scratch (although these forums are a freindly place so you might get lucky) Link to comment Share on other sites More sharing options...
Swimming_Bird Posted July 21, 2006 Author Share Posted July 21, 2006 hrm i dont really have any experience with any encryption methods. that also doesnt solve the problem of being a fixed number of characters each time regardless of the password/keyword. Link to comment Share on other sites More sharing options...
/dev/null Posted July 21, 2006 Share Posted July 21, 2006 I'd like to generate a 12 character encrypted string that would always be 12 char and would always be uneque based on the password and keyword given.The problem with _StringEncrypt is that the lenght is based on the keyword so longer keywords would generate massive codes.If your not going to decrypt it, why not just cut the encrypted string off after 12 characters?CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Swimming_Bird Posted July 21, 2006 Author Share Posted July 21, 2006 bhat about for things that result in less then 12 chars? a fixed list of ammendable chars doesnt seem like htat good an idea. Link to comment Share on other sites More sharing options...
Swimming_Bird Posted July 21, 2006 Author Share Posted July 21, 2006 (edited) also it appears as though the result of _StringEncrypt is that each passcode char is encrypted into 4 chars. so if i cut it off at 12 char the string abcd would return the same as abcde or abcqbasically i'm trying to make an app version of this web site: http://www.hashapass.com/here's the code i wrote:#include <GUIConstants.au3> #include <string.au3> GUICreate ( 'Passgen' , 280 , 135 ) GUICtrlCreateLabel ( 'Keyword (Reminds you of what the password is used for)' , 3 , 3 ) $keyword=GUICtrlCreateInput ( '' , 3 , 20 , 275 ) GUICtrlCreateLabel ( 'Passcode (Keep secret used to encode)' , 3 , 43 ) $passcode=GUICtrlCreateInput ( '' , 3 , 60 , 275 , -1 , $ES_AUTOHSCROLL + $ES_LEFT + $ES_PASSWORD ) $button=GUICtrlCreateButton ( 'Create Password' , 3 , 83 , 275 ) $output=GUICtrlCreateInput ( '' , 3 , 110, 275 , 20 , $ES_READONLY ) GUISetState() HotKeySet ( '{ENTER}' , '_Encrypt' ) While WinActive ( 'Passgen' ) $msg = GUIGetMsg() Select Case $msg = $button _Encrypt() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func _Encrypt () $encrypted = _StringEncrypt ( 1 , GUICtrlRead ( $keyword ) , GUICtrlRead ( $passcode ) ) GUICtrlSetData ( $output , $encrypted ) ClipPut ( $encrypted ) EndFunc Edited July 21, 2006 by Swimming_Bird Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 21, 2006 Moderators Share Posted July 21, 2006 (edited) While 1 If MsgBox(4, 'Testing Password', 'Your Password is: ' & _GeneratePassword() & @CRLF & 'Would you like to generate another?') = 7 Then Exit WEnd Func _GeneratePassword($s_SpecialCharacters = "#,$,?", $s_Dilemeter = ',', $i_PasswordLen = 12, $n_Lower_az = 3, $n_Upper_AZ = 3, $n_Numb09 = 3, $n_SpecialChar = 3) If $n_Lower_az + $n_Upper_AZ + $n_Numb09 + $n_SpecialChar <> $i_PasswordLen Then Return SetError(1, 0, 0) Local $s_Character = StringSplit($s_SpecialCharacters, $s_Dilemeter) Local $i_StringLenSC = StringLen(StringReplace($s_SpecialCharacters, $s_Dilemeter, '')) Local $i_Random[3], $s_Password = '', $i_Count[5] Do $i_Random[1] = Random(1, 4, 1) If $i_Random[1] = 1 And $i_Count[1] < $n_Lower_az Then $i_Count[1] += 1 $i_Random[2] = Random(1, 26, 1) $s_Password &= Chr($i_Random[2] + 96) ElseIf $i_Random[1] = 2 And $i_Count[2] < $n_Upper_AZ Then $i_Count[2] += 1 $i_Random[2] = Random(1, 26, 1) $s_Password &= Chr($i_Random[2] + 64) ElseIf $i_Random[1] = 3 And $i_Count[3] < $n_Numb09 Then $i_Count[3] += 1 $i_Random[2] = Random(0, 9, 1) $s_Password &= $i_Random[2] ElseIf $i_Random[1] = 4 And $i_Count[4] < $n_SpecialChar Then $i_Count[4] += 1 $i_Random[2] = Random(1, $i_StringLenSC, 1) $s_Password &= $s_Character[$i_Random[2]] EndIf Until StringLen($s_Password) = $i_PasswordLen Return $s_Password EndFunc Edit: Code Tags Edit2: Been a while since I used that, cleaned it up just a little. Edited July 21, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 21, 2006 Moderators Share Posted July 21, 2006 (edited) Here's another option looking at your GUI, you'll have to think of something good for the keyword thing... expandcollapse popup#include <GUIConstants.au3> #include <string.au3> GUICreate ( 'Passgen' , 280 , 135 ) GUICtrlCreateLabel ( 'Keyword (Reminds you of what the password is used for)' , 3 , 3 ) $keyword=GUICtrlCreateInput ( '' , 3 , 20 , 275 ) GUICtrlCreateLabel ('Passcode (Keep secret used to encode)' , 3 , 43 ) $passcode=GUICtrlCreateInput ( '' , 3 , 60 , 275 , -1 , $ES_AUTOHSCROLL + $ES_LEFT + $ES_PASSWORD ) GUICtrlSetLimit($passcode, 6, 6);;;;;;;;;;;;;;; Note the limit set ;;;;;;;;;;;;;;;;;;;;;; $button=GUICtrlCreateButton ( 'Create Password' , 3 , 83 , 275 ) $output=GUICtrlCreateInput ( '' , 3 , 110, 275 , 20 , $ES_READONLY ) GUISetState() HotKeySet ( '{ENTER}' , '_Encrypt' ) While WinActive ( 'Passgen' ) $msg = GUIGetMsg() Select Case $msg = $button _Encrypt() MsgBox(64, 'Info', 'Just to show it can be converted back' & @CR & _ConvertMask(GUICtrlRead($output))) Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func _Encrypt () $Mask = _ConvertString(GUICtrlRead($passcode)) GUICtrlSetData ($output , $Mask) ClipPut($Mask) EndFunc Func _ConvertString($sText, $iMask = 20) Local $vOutPut For $iCount = 1 To StringLen($sText) $vOutPut &= Chr(Asc(StringMid($sText, $iCount, 1))+$iMask) Next Return _StringToHex($vOutPut) EndFunc Func _ConvertMask($vText, $iMask = 20) $vText = _HexToString($vText) Local $vOutPut For $iCount = 1 To StringLen($vText) $vOutPut &= Chr(Asc(StringMid($vText, $iCount, 1))-$iMask) Next Return $vOutPut EndFuncEdit: Didn't paste the whole code. Edited July 21, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
/dev/null Posted July 21, 2006 Share Posted July 21, 2006 (edited) bhat about for things that result in less then 12 chars? a fixed list of ammendable chars doesnt seem like htat good an idea.Well, then fill up your unencrypted data with some defined text until the encrypted data will allways generate at least 12 characters. That's called padding.CheersKurt Edited July 21, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Swimming_Bird Posted July 21, 2006 Author Share Posted July 21, 2006 jesus when you quoted my text i realized just how many typeos i had. i need to focus a lot more 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