AutoIT如何加密单个文件

时间:2014-04-22 02:24:06

标签: arrays encryption autoit

所以这是我目前的代码:

Local $source = "C:\Users\EXAMPLE\Documents\EXAMPLE"
Local $password = "Example"

Local $array = _FileListToArrayRec($source, "*", 1, , 1, 2); LOADS ALL FILES FROM $source AS AN ARRAY

我不知道如何从那里继续,因为我想要做的是获取该数组中的所有文件并加密它们。但这就是出现另一个问题的地方,我如何加密所有文件并将它们保存在相同的位置?

示例:_Crypt_EncryptFile($sSourceFile, $sDestinationFile, $vCryptKey, $iALG_ID)接收文件并将未加密的版本保存到另一个位置,如何使其加密版本覆盖原始文件?我在这里非常难过,并且用Google搜索了多个主题,找不到任何可以帮助我的东西,所以我来到这里希望能找到答案。无论如何都要提前感谢。

2 个答案:

答案 0 :(得分:0)

#include <Crypt.au3>
#include <File.au3>

Local $sSource = "C:\Users\EXAMPLE\Documents\EXAMPLE"
Local $sPassword = "Example"

Local $aArray = _FileListToArrayRec($sSource, "*", 1, 1, 1, 2); LOADS ALL FILES FROM $sSource AS AN ARRAY AND AS A FULLPATH
If Not @error Then
    For $i = 1 To $aArray[0]
        If Not _Crypt_EncryptFile($aArray[$i], $aArray[$i], $sPassword, $CALG_AES_256) Then
            ConsoleWrite("Error: " & @error & ", " & $aArray[$i] & @CRLF)
        EndIf
    Next
EndIf

答案 1 :(得分:0)

如果您需要AutoIt的文件加密,请考虑此处列出的解决方案

https://www.autoitscript.com/forum/topic/178131-autoit-string-files-encryption/

它对文件使用多态(随机)加密,并在AutoIt中生成输出代码,文件内容已加密:

; encrypted with https://www.stringencrypt.com (v1.0.0) [AutoIt]
#include <Array.au3>

; $Label = "Fast & easy AutoIt string and file encryption."
Global $Label[47] = [ 0xC254, 0xC273, 0xC261, 0xC260, 0xC212, 0xC236, 0xC202, 0xC24B, _
                      0xC253, 0xC281, 0xC277, 0xC20C, 0xC22B, 0xC277, 0xC27E, 0xC27D, _
                      0xC21B, 0xC280, 0xC22A, 0xC281, 0xC27E, 0xC25A, 0xC237, 0xC232, _
                      0xC255, 0xC21C, 0xC24F, 0xC22A, 0xC24E, 0xC214, 0xC248, 0xC247, _
                      0xC23E, 0xC237, 0x3E0A, 0xC233, 0xC234, 0xC251, 0xC27C, 0xC227, _
                      0xC282, 0xC280, 0xC247, 0xC27D, 0xC224, 0xC23E, 0x3D92 ];

For $SYdIB = 0 to 46
    $fWyHA = $Label[$SYdIB];
    $fWyHA += $SYdIB;
    $fWyHA = BitNOT($fWyHA);
    $fWyHA = BitXOR($fWyHA, $SYdIB);
    $fWyHA += $SYdIB;
    $fWyHA -= $SYdIB;
    $fWyHA = BitXOR($fWyHA, $SYdIB);
    $fWyHA = $fWyHA - 1;
    $fWyHA = BitXOR($fWyHA, $SYdIB);
    $fWyHA = $fWyHA + 1;
    $fWyHA += $SYdIB;
    $fWyHA = BitXOR($fWyHA, 0xC212);
    $fWyHA = BitNOT($fWyHA);
    $fWyHA += $SYdIB;
    $Label[$SYdIB] = ChrW(BitAND($fWyHA, 0xFFFF));
Next

$Label = _ArrayToString($Label, "")

ConsoleWrite($Label);

由于复杂且随机的解密代码,反欺诈者也很难克服这一点。