Advertisement
Guest User

Encryption Tool By MoHaNaD -

a guest
Nov 5th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1.  
  2. #include <ComboConstants.au3>
  3. #include <Crypt.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <String.au3>
  7. ; #include files for encryption and GUI constants
  8.  
  9. _Main()
  10.  
  11. Func _Main()
  12. ; Creates window
  13. GUICreate('Encryption Tool By MoHaNaD -', 400, 400)
  14.  
  15. ; Creates main edit
  16. Local $idEditText = GUICtrlCreateEdit('', 5, 5, 380, 350)
  17.  
  18. ; Creates the password box with blured/centered input
  19. Local $idInputPass = GUICtrlCreateInput('', 5, 360, 100, 20, BitOR($ES_CENTER, $ES_PASSWORD))
  20.  
  21. ; Cretae the combo to select the crypting algorithm
  22. Local $idCombo = GUICtrlCreateCombo("", 110, 360, 90, 20, $CBS_DROPDOWNLIST)
  23. GUICtrlSetData($idCombo, "3DES|AES (128bit)|AES (192bit)|AES (256bit)|DES|RC2|RC4", "RC4")
  24.  
  25. ; Encryption/Decryption buttons
  26. Local $idEncryptButton = GUICtrlCreateButton('Encrypt', 210, 360, 85, 35)
  27. Local $idDecryptButton = GUICtrlCreateButton('Decrypt', 300, 360, 85, 35)
  28.  
  29. ; Simple text labels so you know what is what
  30. GUICtrlCreateLabel('Password', 5, 385)
  31. GUICtrlCreateLabel('Crypting Algorithm', 110, 385)
  32.  
  33. ; Shows window
  34. GUISetState()
  35.  
  36. Local $iAlgorithm = $CALG_RC4
  37. Local $dEncrypted
  38.  
  39. While 1
  40. Switch GUIGetMsg()
  41. Case $GUI_EVENT_CLOSE
  42. ExitLoop
  43.  
  44. Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
  45. Switch GUICtrlRead($idCombo) ; Read the combobox selection.
  46. Case "3DES"
  47. $iAlgorithm = $CALG_3DES
  48.  
  49. Case "AES (128bit)"
  50. $iAlgorithm = $CALG_AES_128
  51.  
  52. Case "AES (192bit)"
  53. $iAlgorithm = $CALG_AES_192
  54.  
  55. Case "AES (256bit)"
  56. $iAlgorithm = $CALG_AES_256
  57.  
  58. Case "DES"
  59. $iAlgorithm = $CALG_DES
  60.  
  61. Case "RC2"
  62. $iAlgorithm = $CALG_RC2
  63.  
  64. Case "RC4"
  65. $iAlgorithm = $CALG_RC4
  66.  
  67. EndSwitch
  68.  
  69. Case $idEncryptButton
  70. ; When you press Encrypt
  71.  
  72. ; Calls the encryption. Sets the data of editbox with the encrypted string
  73. $dEncrypted = _Crypt_EncryptData(GUICtrlRead($idEditText), GUICtrlRead($idInputPass), $iAlgorithm) ; Encrypt the text with the new cryptographic key.
  74. GUICtrlSetData($idEditText, $dEncrypted)
  75.  
  76. Case $idDecryptButton
  77. ; When you press Decrypt
  78.  
  79. ; Calls the encryption. Sets the data of editbox with the encrypted string
  80. $dEncrypted = _Crypt_DecryptData(GUICtrlRead($idEditText), GUICtrlRead($idInputPass), $iAlgorithm) ; Decrypt the data using the generic password string. The return value is a binary string.
  81. GUICtrlSetData($idEditText, BinaryToString($dEncrypted))
  82.  
  83. EndSwitch
  84. WEnd
  85. EndFunc ;==>_Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement