Encrypt.ahkCode:
SetBatchLines -1
#NoTrayIcon
#SingleInstance Off
Loop %0%
File := %A_Index%
RegRead Setting, HKEY_CURRENT_USER, Software\Simcrypt
if (Setting = "Unique")
{
if (A_OSVersion = "WIN_VISTA")
RegRead Key, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductID
else
RegRead Key, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion, ProductID
goto Encrypt
}
else if (Setting = "User")
RegRead Key, HKEY_CURRENT_USER, Software\Simcrypt, User
else
{
Gui Add, Edit, vKey w125
Gui Add, Button, x43 default, Encrypt
Gui Show,, Key
return
}
ButtonEncrypt:
Gui Submit
Encrypt:
BinRead(File, Text, 0, 0)
FileGetSize Size, %File%, M
if Size > 0
FileCopy %File%, %File%.bak
FileDelete %File%
FileAppend % VxEncrypt(Key, Text), %File%
FileDelete %File%.bak
GuiClose:
ExitApp
VxEncrypt(key, message, CryptEvent = "")
{
LowerBound = 34
UpperBound = 126
StringReplace, Message, Message, `r`n, `n, all
StringLeft, CryptEvent, CryptEvent, 1
If !CryptEvent
CryptEvent = e
Loop, parse, key
key .= "`n" Asc(A_LoopField)
key := SubStr(key, InStr(Key, "`n",0,1)+1)
NewMessage =
Loop, Parse, Message
{
code := Asc(A_LoopField)
If ( code >= LowerBound ) && ( code <= UpperBound )
{
mco := code
prevc := A_Index
newkey := ""
Loop, Parse, key, `n
code := Clamp(( code - (A_LoopField * ( Mod(A_LoopField, 2)
* 2 - 1 )) * ((CryptEvent = "e") * 2 - 1) ), LowerBound, UpperBound )
If CryptEvent = e
mco := code
Loop, Parse, key, `n
newkey .= "`n" (prevc := Clamp((A_LoopField + mco * (Mod((mco
+Prevc), 2) * 2 - 1) + Prevc), 1, 255))
key := SubStr( newkey, 2 )
}
NewMessage .= Chr(code)
}
return % NewMessage
}
clamp( number, low, high )
{
span := (high - low + (high > low)*2 - 1)
return number + span * Round(((low-number)/2 + (high-number)/2)/span)
}
BinRead(file, ByRef data, n=0, offset=0)
{
h := DllCall("CreateFile","Str",file,"Uint",0x80000000,"Uint",3,"UInt",0,"UInt",3,"Uint",0,"UInt",0)
IfEqual h,-1, SetEnv, ErrorLevel, -1
IfNotEqual ErrorLevel,0,Return,0
m = 0
IfLess offset,0, SetEnv,m,2
r := DllCall("SetFilePointerEx","Uint",h,"Int64",offset,"UInt *",p,"Int",m)
IfEqual r,0, SetEnv, ErrorLevel, -3
IfNotEqual ErrorLevel,0, {
t = %ErrorLevel%
DllCall("CloseHandle", "Uint", h)
ErrorLevel = %t%
Return 0
}
TotalRead = 0
data =
IfEqual n,0, SetEnv n,0xffffffff
format = %A_FormatInteger%
SetFormat Integer, Hex
Loop %n%
{
result := DllCall("ReadFile","UInt",h,"UChar *",c,"UInt",1,"UInt *",Read,"UInt",0)
if (!result or Read < 1 or ErrorLevel)
break
TotalRead += Read
c += 0
StringTrimLeft c, c, 2
c = 0%c%
StringRight c, c, 2
data = %data%%c%
}
IfNotEqual ErrorLevel,0, SetEnv,t,%ErrorLevel%
h := DllCall("CloseHandle", "Uint", h)
IfEqual h,-1, SetEnv, ErrorLevel, -2
IfNotEqual t,,SetEnv, ErrorLevel, %t%
SetFormat Integer, %format%
Totalread += 0
Return TotalRead
}
Decrypt.ahkCode:
SetBatchLines -1
#NoTrayIcon
#SingleInstance Off
Loop %0%
File := %A_Index%
FileRead Text, %File%
RegRead Setting, HKEY_CURRENT_USER, Software\Simcrypt
if (Setting = "Unique")
{
if (A_OSVersion = "WIN_VISTA")
RegRead Key, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductID
else
RegRead Key, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion, ProductID
goto Decrypt
}
else if (Setting = "User")
RegRead Key, HKEY_CURRENT_USER, Software\Simcrypt, User
else
{
Gui Add, Edit, vKey w125
Gui Add, Button, x43 default, Decrypt
Gui Show,, Key
return
}
ButtonDecrypt:
Gui Submit
Decrypt:
BinText := VxEncrypt(Key, Text,1)
FileDelete %File%
BinWrite(File, BinText, 0, 0)
GuiClose:
ExitApp
VxEncrypt(key, message, CryptEvent = "")
{
LowerBound = 34
UpperBound = 126
StringReplace, Message, Message, `r`n, `n, all
StringLeft, CryptEvent, CryptEvent, 1
If !CryptEvent
CryptEvent = e
Loop, parse, key
key .= "`n" Asc(A_LoopField)
key := SubStr(key, InStr(Key, "`n",0,1)+1)
NewMessage =
Loop, Parse, Message
{
code := Asc(A_LoopField)
If ( code >= LowerBound ) && ( code <= UpperBound )
{
mco := code
prevc := A_Index
newkey := ""
Loop, Parse, key, `n
code := Clamp(( code - (A_LoopField * ( Mod(A_LoopField, 2)
* 2 - 1 )) * ((CryptEvent = "e") * 2 - 1) ), LowerBound, UpperBound )
If CryptEvent = e
mco := code
Loop, Parse, key, `n
newkey .= "`n" (prevc := Clamp((A_LoopField + mco * (Mod((mco
+Prevc), 2) * 2 - 1) + Prevc), 1, 255))
key := SubStr( newkey, 2 )
}
NewMessage .= Chr(code)
}
return % NewMessage
}
clamp( number, low, high )
{
span := (high - low + (high > low)*2 - 1)
return number + span * Round(((low-number)/2 + (high-number)/2)/span)
}
BinWrite(file, data, n=0, offset=0)
{
h := DllCall("CreateFile","str",file,"Uint",0x40000000,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0)
IfEqual h,-1, SetEnv, ErrorLevel, -1
IfNotEqual ErrorLevel,0,Return,0
m = 0
IfLess offset,0, SetEnv,m,2
r := DllCall("SetFilePointerEx","Uint",h,"Int64",offset,"UInt *",p,"Int",m)
IfEqual r,0, SetEnv, ErrorLevel, -3
IfNotEqual ErrorLevel,0, {
t = %ErrorLevel%
DllCall("CloseHandle", "Uint", h)
ErrorLevel = %t%
Return 0
}
TotalWritten = 0
m := Ceil(StrLen(data)/2)
If (n <= 0 or n > m)
n := m
Loop %n%
{
StringLeft c, data, 2
StringTrimLeft data, data, 2
c = 0x%c%
result := DllCall("WriteFile","UInt",h,"UChar *",c,"UInt",1,"UInt *",Written,"UInt",0)
TotalWritten += Written
if (!result or Written < 1 or ErrorLevel)
break
}
IfNotEqual ErrorLevel,0, SetEnv,t,%ErrorLevel%
h := DllCall("CloseHandle", "Uint", h)
IfEqual h,-1, SetEnv, ErrorLevel, -2
IfNotEqual t,,SetEnv, ErrorLevel, %t%
Return TotalWritten
}
Install.ahkCode:
#NoTrayIcon
SetBatchLines -1
Gui -Caption
Gui Color, 0x80B2D3
Gui Add, Edit, r10 ReadOnly,
(
SYMCRYPT v. 1.4
------------------------------
V 1.4
Context Menu support for all file types
Backup files larger than 1MB during encryption
V 1.3
New encryption method
Read/Write binary
v 1.2
Encrypt .txt files
- Drag-n-Drop to the EXE or
- Right click the .txt file and choose Encrypt.
- Computer Specific Key
- Set default key
About Simcrypt
-----------------
Simcrypt is a simple encryption program.
Currently Simcrypt can only encrypt simple text files.
This program should not be used for any serious
purposes, the encryption level is very weak and
errors may occur.
Any feedback or questions can be sent to
abhishek.regmi@gmail.com
Use at your own risk.
)
Gui Font, s15
Gui Add, Button, w100 x30 y150,Install
Gui Add, Button, w100 x145 y150, Exit
Gui Show, w280 h200
return
ButtonInstall:
IfExist %A_ProgramFiles%\Simpcrypt\
FileRemoveDir, %A_ProgramFiles%\Simpcrypt\, 1
FileCreateDir %A_ProgramFiles%\Simpcrypt\
FileInstall Encrypt.exe, %A_ProgramFiles%\Simpcrypt\Encrypt.exe
FileInstall Decrypt.exe, %A_ProgramFiles%\Simpcrypt\Decrypt.exe
FileInstall Options.exe, %A_ProgramFiles%\Simpcrypt\Options.exe
FileInstall Uninstall.exe, %A_ProgramFiles%\Simpcrypt\Uninstall.exe
FileCreateDir %A_StartMenuCommon%\Simpcrypt\
FileCreateShortcut %A_ProgramFiles%\Simpcrypt\Options.exe, %A_StartMenuCommon%\Simpcrypt\Options.lnk
FileCreateShortcut %A_ProgramFiles%\Simpcrypt\Uninstall.exe, %A_StartMenuCommon%\Simpcrypt\Uninstall.lnk
RegWrite REG_SZ, HKEY_CLASSES_ROOT, *\shell\Encrypt\Command, , "%A_ProgramFiles%\Simpcrypt\Encrypt.exe" "`%0"
RegWrite REG_SZ, HKEY_CLASSES_ROOT, *\shell\Decrypt\Command, , "%A_ProgramFiles%\Simpcrypt\Decrypt.exe" "`%0"
Msgbox Symcrypt has successfully been installed!
ButtonExit:
GuiClose:
ExitApp
Uninstall.ahkCode:
FileRemoveDir %A_ProgramFiles%\Simpcrypt\, 1
FileRemoveDir %A_StartMenuCommon%\Simpcrypt, 1
RegDelete HKEY_CLASSES_ROOT, *\shell\Encrypt\
RegDelete HKEY_CLASSES_ROOT, *\shell\Decrypt\
RegDelete HKEY_CURRENT_USER, Software\Simcrypt
Msgbox Symcrypt has successfully been uninstalled!
Options.ahkCode:
#SingleInstance Force
SetBatchLines -1
RegRead Setting, HKEY_CURRENT_USER, Software\Simcrypt
Gui Color, 0x80B2D3
Gui Add, Text, , OPTIONS
Gui Add, CheckBox, x15 y30 vUnique, Auto-Gen Key
Gui Add, CheckBox, x15 y50 vDefault, User Defined Key
Gui Add, Edit, x25 y72 vUserKey, Pur|_01n3d
Gui Add, CheckBox, x15 y95 vSelect, Manual Key
Gui Add, Button, default, Submit
if (Setting = Unique)
GuiControl, , Unique, 1
else if (Setting = User)
{
RegRead UserKey, HKEY_CURRENT_USER, Software\Simcrypt, User
GuiControl, , Default, 1
GuiControl, , UserKey, %UserKey%
}
else
GuiControl, , Select, 1
Gui Show, w250 h200, Encrypt Options
return
ButtonSubmit:
Gui Submit
if (Unique = 1)
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Simcrypt, , Unique
else if (Default = 1)
{
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Simcrypt, , User
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Simcrypt, User, %UserKey%
}
else if (Select = 1)
RegWrite REG_SZ, HKEY_CURRENT_USER, Software\Simcrypt, , Manual
Msgbox Changes have been made!
GuiClose:
ExitApp
CreditsVxELaszlo