IDEA File Encryption UDF autolt


SUBMITTED BY: Guest

DATE: May 28, 2013, 6:38 a.m.

FORMAT: Text only

SIZE: 4.5 kB

HITS: 1004

  1. #include<File.au3>
  2. ;===============================================================================
  3. ;
  4. ; Function Name: _FileEncrypt()
  5. ; Description: Encrypts a file using the IDEA Algorithm
  6. ; Parameter(s): $FileInput - File to encrypt
  7. ; $FileOutput - Where to save encrypted file
  8. ; $sKey - Key to encrypt file with
  9. ; Requirement(s): File.au3
  10. ; Return Value(s): On Success - Returns 1
  11. ; On Failure - Sets @error to 1 if input file does not exist
  12. ; - Sets @error to 2 if writing new file fails
  13. ; Author(s): RazerM
  14. ;===============================================================================
  15. ;
  16. Func _FileEncrypt($FileInput, $FileOutput, $sKey)
  17. Select
  18. Case Not FileExists(@TempDir & "\encrypt.com")
  19. _WriteEncryptCom()
  20. Case Not FileExists($FileInput)
  21. Return SetError(1, 0, 0)
  22. EndSelect
  23. $FileTemp = __FileCopy($FileInput, $FileOutput)
  24. If @extended = 0 Then Return SetError(2, 0, 0)
  25. RunWait(@ComSpec & " /c echo " & $sKey & "|" & FileGetShortName(@TempDir & "\encrypt.com") & " + " & FileGetShortName($FileOutput), "", @SW_HIDE)
  26. FileDelete(@TempDir & "\encrypt.com")
  27. FileDelete($FileTemp)
  28. EndFunc ;==>_FileEncrypt
  29. ;===============================================================================
  30. ;
  31. ; Function Name: _FileDecrypt()
  32. ; Description: Decrypt a file using the IDEA Algorithm
  33. ; Parameter(s): $FileInput - File to decrypt
  34. ; $FileOutput - Where to save decrypted file
  35. ; $sKey - Key to decrypt file with
  36. ; Requirement(s): File.au3
  37. ; Return Value(s): On Success - Returns 1
  38. ; On Failure - Sets @error to 1 if input file does not exist
  39. ; - Sets @error to 2 if writing new file fails
  40. ; Author(s): RazerM
  41. ;===============================================================================
  42. ;
  43. Func _FileDecrypt($FileInput, $FileOutput, $sKey)
  44. Select
  45. Case Not FileExists(@TempDir & "\encrypt.com")
  46. _WriteEncryptCom()
  47. Case Not FileExists($FileInput)
  48. Return SetError(1, 0, 0)
  49. EndSelect
  50. If Not FileExists(@TempDir & "\encrypt.com") Then _WriteEncryptCom()
  51. $FileTemp = __FileCopy($FileInput, $FileOutput)
  52. If @extended = 0 Then Return SetError(2, 0, 0)
  53. RunWait(@ComSpec & " /c echo " & $sKey & "|" & FileGetShortName(@TempDir & "\encrypt.com") & " - " & FileGetShortName($FileOutput), "", @SW_HIDE)
  54. FileDelete(@TempDir & "\encrypt.com")
  55. FileDelete($FileTemp)
  56. EndFunc ;==>_FileDecrypt
  57. Func __FileCopy($FileInput, $FileOutput)
  58. Local $NULL, $szDrive, $szDir, $szFName, $szExt
  59. _PathSplit($FileInput, $szDrive, $szDir, $szFName, $szExt)
  60. FileCopy($FileInput, @TempDir, 9)
  61. Return SetError(0, FileMove(@TempDir & "\" & $szFName & $szExt, $FileOutput, 9), @TempDir & "\" & $szFName & $szExt)
  62. EndFunc ;==>__FileCopy
  63. Func _WriteEncryptCom()
  64. Local $com
  65. $com = "0xE81A01BAE402BE8000AC0AC0740AACAC3C2D74073C2B7407E9FE00FE06DD"
  66. $com &= "01ADAC3C2077FB884CFFB2F0B409CD21B2F6B40ACD21B110BEF8025156B1"
  67. $com &= "04BE8203BF9A03F3A55E56E8DC00BE9A03568BFEE8E600B104BE7A03BF8A"
  68. $com &= "0357F3A55F5E56E802018BF7BF7A03E8C3005F5E5657E8B300B104BE8A03"
  69. $com &= "F3A55E8BFEE8B900B104BE8203BF92035657F3A55F57BE9A03E8D2005E5F"
  70. $com &= "E896005E83C60859E299BF7A03E89300BA8400B8023DCD21720B93B90080"
  71. $com &= "BA0A04B43FCD2172590BC0745C5250538BFA050700B103D3E891BE7A0351"
  72. $com &= "57BF0204E88D00B904005EF8720FAD86E03305AB86E08944FEE2F3EB0F8B"
  73. $com &= "1DAD86E0AB33D886FB895CFEE2F18BFE59E2CB5B5A52F7DA49B80142CD21"
  74. $com &= "595AB440CD21739BBADE02B409CD21BFF702B91381F3AAC3B104AD86E0AB"
  75. $com &= "E2FAC3B90400AD3305ABE2FAC383C710B3088BC324073C068B45F28B55F4"
  76. $com &= "72088B55E474038B45E2B109D3E0B107D3EA0BC2AB4380FB3475D9C3C606"
  77. $com &= "780308578B158B4D028B6D048B7D06E8500093AD03C8AD03E88BD7E84400"
  78. $com &= "97515533EB33CF8BD5E8380003C8958BD1E8300003E89133D933FD5A5833"
  79. $com &= "CA33E88BD3FE0E780375C8E8180093AD03E8AD03C88BD7E80C005F5793AB"
  80. $com &= "95AB91AB93AB5FC352ADF7E22BC25A7507402B44FE2BC2C3150000C34572"
  81. $com &= "726F72094944454120F12046696C65244B65793A202480"
  82. $hEncryptCom = FileOpen(@TempDir & "\encrypt.com", 2+16)
  83. FileWrite($hEncryptCom, Binary($com))
  84. FileClose($hEncryptCom)
  85. EndFunc ;==>_WriteEncryptCom

comments powered by Disqus