#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <Process.au3>
If FileExists(@ScriptDir & '\unupx.au3') Then
FileDelete(@ScriptDir & '\unupx.au3')
EndIf
$hForm = GUICreate("File Crypt v1.0",265,30,-1,-1,-1,$WS_EX_TOOLWINDOW)
$Password = GUICtrlCreateInput("",5,5,150,20,32+0x0080)
$ButtonOpen = GUICtrlCreateButton("Открыть файл",160,5,100,20)
GUICtrlSetState($ButtonOpen,$GUI_DISABLE)
GUISetState()
AdlibRegister('ENABLECTRL',0)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonOpen
$OpenFile = FileOpenDialog ( "File Crypt v1.0", @HomeDrive, "All files (*.*)" , 1, "")
If @error Then
Sleep(0)
Else
$CryptPass = GUICtrlRead($Password)
CreateNewFile($OpenFile,_StringEncrypt(1,$CryptPass,"1"))
_compilation()
Exit
EndIf
EndSwitch
WEnd
Func ENABLECTRL()
$ReadPass = GUICtrlRead($Password)
If $ReadPass <> '' Then
GUICtrlSetState($ButtonOpen,$GUI_ENABLE)
EndIf
EndFunc
Func CreateNewFile($__sFile_Open,$__sPassword)
$__sFile = FileOpen($__sFile_Open,16)
$__sRead_Bin = FileRead($__sFile,1024)
$__sFile_Name = StringRegExp($__sFile_Open,"(^.*)\\(.*)\.(.*)$",3)
$__sWrite_Kode = FileWrite(@ScriptDir & '\unupx.au3', _
'Global $sCriptPass = ' & '"' & $__sPassword & '"' &@CRLF& _
'$hForm = GUICreate("Введите пароль",195,30,-1,-1,-1,0x00000080)' &@CRLF& _
'$sPass = GUICtrlCreateInput("",5,5,150,20,32+0x0080)' &@CRLF& _
'$sButt = GUICtrlCreateButton("OK",160,5,30,20)' &@CRLF& _
'GUISetState()' &@CRLF& _
'While 1' &@CRLF& _
' $nMsg = GUIGetMsg()' &@CRLF& _
' Switch $nMsg' &@CRLF& _
' Case -3' &@CRLF& _
' Exit' &@CRLF& _
' Case $sButt' &@CRLF& _
' $ReadPass = GUICtrlRead($sPass)' &@CRLF& _
' If _StringCript(0,$sCriptPass,"1") = $ReadPass Then' &@CRLF& _
' _CreateFile()' &@CRLF& _
' Else' &@CRLF& _
' MsgBox(16,"File Crypt v1.0","Не верный пароль")' &@CRLF& _
' Exit' &@CRLF& _
' EndIf' &@CRLF& _
' EndSwitch' &@CRLF& _
'WEnd' &@CRLF& _
'' &@CRLF& _
'#include-once' &@CRLF& _
'Func _CreateFile()' &@CRLF& _
' $sData = ' & '"'&$__sRead_Bin&'"' &@CRLF& _
' $sData=Binary($sData)' &@CRLF& _
' $file = FileOpen(@ScriptDir & ' & '"\'&$__sFile_Name[1]&"."&$__sFile_Name[2]&'"'&',18)' &@CRLF& _
' FileWrite($file, $sData)' &@CRLF& _
' FileClose($file)' &@CRLF& _
' Exit' &@CRLF& _
'EndFunc' &@CRLF& _
'' &@CRLF& _
'Func _StringCript($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)' &@CRLF& _
'If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then' &@CRLF& _
'SetError(1, 0, "")' &@CRLF& _
'ElseIf $s_EncryptText = "" Or $s_EncryptPassword = "" Then' &@CRLF& _
'SetError(1, 0, "")' &@CRLF& _
'Else' &@CRLF& _
'If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1' &@CRLF& _
'Local $v_EncryptModified' &@CRLF& _
'Local $i_EncryptCountH' &@CRLF& _
'Local $i_EncryptCountG' &@CRLF& _
'Local $v_EncryptSwap' &@CRLF& _
'Local $av_EncryptBox[256][2]' &@CRLF& _
'Local $i_EncryptCountA' &@CRLF& _
'Local $i_EncryptCountB' &@CRLF& _
'Local $i_EncryptCountC' &@CRLF& _
'Local $i_EncryptCountD' &@CRLF& _
'Local $i_EncryptCountE' &@CRLF& _
'Local $v_EncryptCipher' &@CRLF& _
'Local $v_EncryptCipherBy' &@CRLF& _
'If $i_Encrypt = 1 Then' &@CRLF& _
' For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1' &@CRLF& _
' $i_EncryptCountG = ""' &@CRLF& _
' $i_EncryptCountH = ""' &@CRLF& _
' $v_EncryptModified = ""' &@CRLF& _
' For $i_EncryptCountG = 1 To StringLen($s_EncryptText)' &@CRLF& _
' If $i_EncryptCountH = StringLen($s_EncryptPassword) Then' &@CRLF& _
' $i_EncryptCountH = 1' &@CRLF& _
' Else' &@CRLF& _
' $i_EncryptCountH += 1' &@CRLF& _
' EndIf' &@CRLF& _
' $v_EncryptModified = $v_EncryptModified & Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))' &@CRLF& _
' Next' &@CRLF& _
' $s_EncryptText = $v_EncryptModified' &@CRLF& _
' $i_EncryptCountA = ""' &@CRLF& _
' $i_EncryptCountB = 0' &@CRLF& _
' $i_EncryptCountC = ""' &@CRLF& _
' $i_EncryptCountD = ""' &@CRLF& _
' $i_EncryptCountE = ""' &@CRLF& _
' $v_EncryptCipherBy = ""' &@CRLF& _
' $v_EncryptCipher = ""' &@CRLF& _
' $v_EncryptSwap = ""' &@CRLF& _
' $av_EncryptBox = ""' &@CRLF& _
' Local $av_EncryptBox[256][2]' &@CRLF& _
' For $i_EncryptCountA = 0 To 255' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA' &@CRLF& _
' Next' &@CRLF& _
' For $i_EncryptCountA = 0 To 255' &@CRLF& _
' $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)' &@CRLF& _
' $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap' &@CRLF& _
' Next' &@CRLF& _
' For $i_EncryptCountA = 1 To StringLen($s_EncryptText)' &@CRLF& _
' $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)' &@CRLF& _
' $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)' &@CRLF& _
' $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0]' &@CRLF& _
' $v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)' &@CRLF& _
' $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)' &@CRLF& _
' Next' &@CRLF& _
' $s_EncryptText = $v_EncryptCipher' &@CRLF& _
' Next' &@CRLF& _
'Else' &@CRLF& _
' For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1' &@CRLF& _
' $i_EncryptCountB = 0' &@CRLF& _
' $i_EncryptCountC = ""' &@CRLF& _
' $i_EncryptCountD = ""' &@CRLF& _
' $i_EncryptCountE = ""' &@CRLF& _
' $v_EncryptCipherBy = ""' &@CRLF& _
' $v_EncryptCipher = ""' &@CRLF& _
' $v_EncryptSwap = ""' &@CRLF& _
' $av_EncryptBox = ""' &@CRLF& _
' Local $av_EncryptBox[256][2]' &@CRLF& _
' For $i_EncryptCountA = 0 To 255' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountA][1] = Asc(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA' &@CRLF& _
' Next' &@CRLF& _
' For $i_EncryptCountA = 0 To 255' &@CRLF& _
' $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)' &@CRLF& _
' $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]' &@CRLF& _
' $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap' &@CRLF& _
' Next' &@CRLF& _
' For $i_EncryptCountA = 1 To StringLen($s_EncryptText) Step 2' &@CRLF& _
' $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)' &@CRLF& _
' $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)' &@CRLF& _
' $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0]' &@CRLF& _
' $v_EncryptCipherBy = BitXOR(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE)' &@CRLF& _
' $v_EncryptCipher = $v_EncryptCipher & Chr($v_EncryptCipherBy)' &@CRLF& _
' Next' &@CRLF& _
' $s_EncryptText = $v_EncryptCipher' &@CRLF& _
' $i_EncryptCountG = ""' &@CRLF& _
' $i_EncryptCountH = ""' &@CRLF& _
' $v_EncryptModified = ""' &@CRLF& _
' For $i_EncryptCountG = 1 To StringLen($s_EncryptText)' &@CRLF& _
' If $i_EncryptCountH = StringLen($s_EncryptPassword) Then' &@CRLF& _
' $i_EncryptCountH = 1' &@CRLF& _
' Else' &@CRLF& _
' $i_EncryptCountH += 1' &@CRLF& _
' EndIf' &@CRLF& _
' $v_EncryptModified &= Chr(BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountG, 1)), Asc(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))' &@CRLF& _
' Next' &@CRLF& _
' $s_EncryptText = $v_EncryptModified' &@CRLF& _
' Next' &@CRLF& _
'EndIf' &@CRLF& _
'Return $s_EncryptText' &@CRLF& _
'EndIf' &@CRLF& _
'EndFunc')
If $__sWrite_Kode = 0 Then
Return
Endif
EndFunc
Func _compilation()
If Not FileExists(@ScriptDir & '\unupx.au3') Then
Exit
EndIf
_RunDOS("Plugin\AUExe.exe /in unupx.au3 /out myapp.exe /icon Icon\1.ico /bin Plugin\RunSC.bin")
FileDelete(@ScriptDir & '\unupx.au3')
$OpenDir = FileSaveDialog ("File Crypt v1.0", @HomeDrive, "All files (*.*)", 2+16)
If $OpenDir = 0 Then
$Move = FileMove (@ScriptDir & "\myapp.exe", $OpenDir & ".exe", 1)
FileDelete(@ScriptDir & "\.exe")
EndIf
If $OpenDir = 1 Then
Exit
EndIf
EndFunc