-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
4,164 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[MainGUI] | ||
WinXPos=448 | ||
WinYPos=282 | ||
WinWidth=798 | ||
WinHeight=366 | ||
TreeWidth=250 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
; ----------------------------------------------------------------------------- | ||
; AES Machine Code UDF File Example | ||
; Purpose: Provide Machine Code Version of AES Algorithm In AutoIt | ||
; Author: Ward | ||
; Changes: Return=1 when all ok ([email protected]) | ||
; @error=3 when Source-File not Open ([email protected]) | ||
; @error=4 when Destination-File not Open ([email protected]) | ||
; ----------------------------------------------------------------------------- | ||
|
||
; An example for encrypt/decrypt file by AES algorithm with CBC bit padding/CFB/OFB mode | ||
; This code is not intended for real use since it does not provide integrity checking | ||
|
||
#Include-once | ||
#Include "_AES.au3" | ||
|
||
Global $_AesFileBufferSize = 0x100000 | ||
|
||
Func _AesEncryptFile($Key, $SrcFile, $DestFile, $Mode = $AES_CBC_MODE, $IV = Default) | ||
If Not FileExists($SrcFile) Then Return SetError(1, 0, 0) | ||
|
||
Local $SrcFileSize = FileGetSize($SrcFile) | ||
If $SrcFileSize = 0 Then Return SetError(2, 0, 0) | ||
|
||
Local $SrcFileHandle = FileOpen($SrcFile, 16) | ||
If $SrcFileHandle = -1 Then Return SetError(3, 0, 0) | ||
Local $DestFileHandle = FileOpen($DestFile, 2 + 16) | ||
If $DestFileHandle = -1 Then Return SetError(4, 0, 0) | ||
|
||
$IV = _AesPrepareIV($IV) | ||
Local $Ctx = _AesEncryptKey($Key) | ||
Local $n = Ceiling($SrcFileSize / $_AesFileBufferSize), $Data | ||
|
||
FileWrite($DestFileHandle, $IV) | ||
Switch String($Mode) | ||
Case "CFB", $AES_CFB_MODE | ||
For $i = 1 To $n | ||
$Data = _AesEncryptCFB($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
FileWrite($DestFileHandle, $Data) | ||
Next | ||
Case "OFB", $AES_OFB_MODE | ||
For $i = 1 To $n | ||
$Data = _AesCryptOFB($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
FileWrite($DestFileHandle, $Data) | ||
Next | ||
Case Else | ||
For $i = 1 To $n | ||
If $i <> $n Then | ||
$Data = _AesEncryptCBC($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
Else | ||
$Data = _AesEncryptCBC_Pad($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
EndIf | ||
FileWrite($DestFileHandle, $Data) | ||
Next | ||
EndSwitch | ||
|
||
FileClose($SrcFileHandle) | ||
FileClose($DestFileHandle) | ||
Return SetError(0, 0, 1) | ||
EndFunc | ||
|
||
Func _AesDecryptFile($Key, $SrcFile, $DestFile, $Mode = $AES_CBC_MODE) | ||
If Not FileExists($SrcFile) Then Return SetError(1, 0, 0) | ||
|
||
Local $SrcFileSize = FileGetSize($SrcFile) | ||
If $SrcFileSize < 16 Then Return SetError(2, 0, 0) | ||
|
||
Local $SrcFileHandle = FileOpen($SrcFile, 16) | ||
If $SrcFileHandle = -1 Then Return SetError(3, 0, 0) | ||
Local $DestFileHandle = FileOpen($DestFile, 2 + 16) | ||
If $DestFileHandle = -1 Then Return SetError(4, 0, 0) | ||
|
||
Local $IV = FileRead($SrcFileHandle, 16) | ||
Local $n = Ceiling($SrcFileSize / $_AesFileBufferSize), $Ctx, $Data | ||
|
||
Switch String($Mode) | ||
Case "CFB", $AES_CFB_MODE | ||
$Ctx = _AesEncryptKey($Key) | ||
For $i = 1 To $n | ||
$Data = _AesDecryptCFB($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
FileWrite($DestFileHandle, $Data) | ||
Next | ||
Case "OFB", $AES_OFB_MODE | ||
$Ctx = _AesEncryptKey($Key) | ||
For $i = 1 To $n | ||
$Data = _AesCryptOFB($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
FileWrite($DestFileHandle, $Data) | ||
Next | ||
Case Else | ||
$Ctx = _AesDecryptKey($Key) | ||
For $i = 1 To $n | ||
If $i <> $n Then | ||
$Data = _AesDecryptCBC($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
Else | ||
$Data = _AesDecryptCBC_Pad($Ctx, $IV, FileRead($SrcFileHandle, $_AesFileBufferSize)) | ||
EndIf | ||
FileWrite($DestFileHandle, $Data) | ||
Next | ||
EndSwitch | ||
|
||
FileClose($SrcFileHandle) | ||
FileClose($DestFileHandle) | ||
Return SetError(0, 0, 1) | ||
EndFunc |
Oops, something went wrong.