Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Encryption Utility - 128bit protection [UPDATED]


  • Please log in to reply
17 replies to this topic
Cephei1
  • Members
  • 396 posts
  • Last active: Jan 22 2014 08:19 PM
  • Joined: 04 Aug 2008
Encryption Utility

I just whipped this up quickly, nothing major. It provides 128bit protection to text files. However, as many of you have requested, it can be redesigned (the GUI and it's operation) so that you don't need to save your data to a text file each time you want to encrypt it. A simple Edit box to enter data and a Text box to show the encrypted/decrypted data would be much more handy.

I am no longer working on this project so feel free to add the above functionality yourself. The source is available under Downloads below.

Request of credits
Two functions: Lazlo and [VxE]
This code: Cephei1 (me)
Please respect other people's work.
Features
- Drag and Drop files onto the .ahk or .exe file (not the GUI) to encrypt/decrypt
- Select files manually
- Converted files are saved in the same folder with a this in its name "_Encrypted" or "_Decrypted"
Download
Compiled Version
Source
Previews
Posted Image
Cephei1

Ahk_L (Unicode 32-bit)


Guest
  • Guests
  • Last active:
  • Joined: --
Looks nice but:

• can you do the same for all files? Like exe, too?
• could you use a tray-tip or something else but not a msgbox which pops-up every time?
Or create a text control for it.

Thank you.

Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
you don't wanna give the method ? :)

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


Cephei1
  • Members
  • 396 posts
  • Last active: Jan 22 2014 08:19 PM
  • Joined: 04 Aug 2008
LOL the method is simple it uses these two functions. I don't know who they belong to. Apologies to the owner.
Decrypt(Data,Pass) {
	b := 0, j := 0, x := "0x"
	VarSetCapacity(Result,StrLen(Data)//2)
	Loop 256
		a := A_Index - 1
		,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1)) 
		,sBox%a% := a
	Loop 256
		a := A_Index - 1
		,b := b + sBox%a% + Key%a%  & 255
		,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%) ; SWAP(a,b)
	Loop % StrLen(Data)//2
		i := A_Index  & 255
		,j := sBox%i% + j  & 255
		,k := sBox%i% + sBox%j%  & 255
		,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%) ; SWAP(i,j)
		,Result .= Chr((x . SubStr(Data,2*A_Index-1,2)) ^ sBox%k%)
   	Return Result
}
Return

Encrypt(Data,Pass) { 
	Format := A_FormatInteger 
	SetFormat Integer, Hex 
	b := 0, j := 0 
	VarSetCapacity(Result,StrLen(Data)*2) 
	Loop 256 
		a := A_Index - 1 
		,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1)) 
		,sBox%a% := a 
	Loop 256 
		a := A_Index - 1 
		,b := b + sBox%a% + Key%a%  & 255 
		,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%) ; SWAP(a,b) 
	Loop Parse, Data 
		i := A_Index & 255 
		,j := sBox%i% + j  & 255 
		,k := sBox%i% + sBox%j%  & 255 
		,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%) ; SWAP(i,j) 
		,Result .= SubStr(Asc(A_LoopField)^sBox%k%, -1, 2) 
	StringReplace Result, Result, x, 0, All 
	SetFormat Integer, %Format% 
	Return Result 
}

Ahk_L (Unicode 32-bit)


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
I already got the method ^^ why you did use the exe protector ?

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


rbrtryn
  • Members
  • 1177 posts
  • Last active: Sep 11 2013 08:04 PM
  • Joined: 22 Jun 2011

the method is simple it uses these two functions. I don't know who they belong to.

Looks like Laszlo and [VxE] deserve credit, see here.

My Scripts are written for the latest released version of AutoHotkey.

Need a secure, accessible place to backup your stuff? Use Dropbox!


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
RC4hex2txt(Data,Pass) or RC4txt2hex(Data,Pass) , Yes rbrtryn is right

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


  • Guests
  • Last active:
  • Joined: --
; <COMPILER: v1.1.07.03>

MsgBox, 64, Encryption Utility, Created by Cephei1`n`nCephei1@hotmail.co.uk`nhttp://www.autohotkey.com/community/viewtopic.php?f=2&t=89137

#Persistent

#SingleInstance, Force

#NoEnv

#NoTrayIcon

ListLines, Off

SetWinDelay,-1

SetBatchLines,-1

FilePath = %1%

Loop, %FilePath% {

FilePath := A_LoopFileLongPath

Break

}

If !! FilePath

{

IfExist, % FilePath

{

FileRead, Data, % FilePath

SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt

}

}

Else

Dir := "None", FileName := "None"

Gui, Font, S10, Verdana

Gui, +Resize MinSize500x100

Gui, Add, Button, gSelectFile, Select a file

Gui, Add, Text, , Path:`t`n`nName:

Gui, Add, Text, x+ yp w480 vDir, %Dir%`n

Gui, Add, Text, xp y+ w480 vFileName, %FileName%

Gui, Add, Button, x10 y+10 gEncrypt, Encrypt

Gui, Add, Button, x+10 yp gDecrypt, Decrypt

Gui, Show, , Encryption Utility

Return

GuiEscape:

GuiClose:

ExitApp

SelectFile:

FileSelectFile, FilePath, , % A_MyDocuments, Select a file, Text Documents (*.txt)

If ErrorLevel

Return

If (!FilePath || FilePath = "None")

Return

IfExist, % FilePath

{

SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt

GuiControl, , Dir, %Dir%

GuiControl, , FileName, %FileName%

FileRead, Data, % FilePath

}

Return

Encrypt:

If FilePath = None

{

Msgbox, 64, Encryption Utility, You did not select a file!

Return

}

InputBox, Pass, Encrypt, Enter a password to use for encryption.`n(You can encrypt without a password too)

If Errorlevel

{

Msgbox, 64, Encryption Utility, You cancelled. Try again...

Return

}

SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt

FileRead, Data, % FilePath

SavePath := Dir "\" FileNameNoExt "_Encrypted." Ext

FileDelete, % SavePath

FileAppend, % Encrypt(Data,Pass), % SavePath

Msgbox, 64, Encryption Utility, '%FileName%.%Ext%' Encrypted!`nNew encrypted version is saved in the same folder as the original.

Run % "explorer.exe /select," SavePath

Return

Decrypt:

If FilePath = None

{

Msgbox, 64, Encryption Utility, You did not select a file!

Return

}

InputBox, Pass, Decrypt, Enter a password to use for decryption (if you set one).

If Errorlevel

{

Msgbox, 64, Encryption Utility, You cancelled. Try again...

Return

}

SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt

FileRead, Data, % FilePath

SavePath := Dir "\" FileNameNoExt "_Decrypted." Ext

FileDelete, % SavePath

FileAppend, % Decrypt(Data,Pass), % SavePath

Msgbox, 64, Encryption Utility, '%FileName%.%Ext%' Decrypted!`nNew Decrypted version is saved in the same folder as the original.

Run % "explorer.exe /select," SavePath

Return

Decrypt(Data,Pass) {

b := 0, j := 0, x := "0x"

VarSetCapacity(Result,StrLen(Data)//2)

Loop 256

a := A_Index - 1

,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1))

,sBox%a% := a

Loop 256

a := A_Index - 1

,b := b + sBox%a% + Key%a%  & 255

,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%)

Loop % StrLen(Data)//2

i := A_Index  & 255

,j := sBox%i% + j  & 255

,k := sBox%i% + sBox%j%  & 255

,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%)

,Result .= Chr((x . SubStr(Data,2*A_Index-1,2)) ^ sBox%k%)

Return Result

}

Return

Encrypt(Data,Pass) {

Format := A_FormatInteger

SetFormat Integer, Hex

b := 0, j := 0

VarSetCapacity(Result,StrLen(Data)*2)

Loop 256

a := A_Index - 1

,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1))

,sBox%a% := a

Loop 256

a := A_Index - 1

,b := b + sBox%a% + Key%a%  & 255

,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%)

Loop Parse, Data

i := A_Index & 255

,j := sBox%i% + j  & 255

,k := sBox%i% + sBox%j%  & 255

,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%)

,Result .= SubStr(Asc(A_LoopField)^sBox%k%, -1, 2)

StringReplace Result, Result, x, 0, All

SetFormat Integer, %Format%

Return Result

}


Cephei1
  • Members
  • 396 posts
  • Last active: Jan 22 2014 08:19 PM
  • Joined: 04 Aug 2008
Always a guest isn't it. Too shy to reveal name :p

Ahk_L (Unicode 32-bit)


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
and I syntaxed it ^^ lololol

; <COMPILER: v1.1.07.03>
MsgBox, 64, Encryption Utility, Created by Cephei1`n`nCephei1@hotmail.co.uk`nhttp://www.autohotkey.com/community/viewtopic.php?f=2&t=89137
#Persistent
#SingleInstance, Force
#NoEnv
#NoTrayIcon
ListLines, Off
SetWinDelay,-1
SetBatchLines,-1

FilePath = %1%
Loop, %FilePath% {
	FilePath := A_LoopFileLongPath
	Break
}
If !! FilePath
{
	IfExist, % FilePath
	{
		FileRead, Data, % FilePath
		SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt
	}
}
Else
Dir := "None", FileName := "None"
Gui, Font, S10, Verdana
Gui, +Resize MinSize500x100
Gui, Add, Button, gSelectFile, Select a file
Gui, Add, Text, , Path:`t`n`nName:
Gui, Add, Text, x+ yp w480 vDir, %Dir%`n
Gui, Add, Text, xp y+ w480 vFileName, %FileName%
Gui, Add, Button, x10 y+10 gEncrypt, Encrypt
Gui, Add, Button, x+10 yp gDecrypt, Decrypt
Gui, Show, , Encryption Utility
Return

GuiEscape:
GuiClose:
ExitApp

SelectFile:
FileSelectFile, FilePath, , % A_MyDocuments, Select a file, Text Documents (*.txt)
If ErrorLevel
	Return
If (!FilePath || FilePath = "None")
	Return
IfExist, % FilePath
{
	SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt
	GuiControl, , Dir, %Dir%
	GuiControl, , FileName, %FileName%
	FileRead, Data, % FilePath
}
Return

Encrypt:
If FilePath = None
{
	Msgbox, 64, Encryption Utility, You did not select a file!
	Return
}

InputBox, Pass, Encrypt, Enter a password to use for encryption.`n(You can encrypt without a password too)

If Errorlevel
{
	Msgbox, 64, Encryption Utility, You cancelled. Try again...
	Return
}
SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt
FileRead, Data, % FilePath
SavePath := Dir "\" FileNameNoExt "_Encrypted." Ext
FileDelete, % SavePath
FileAppend, % Encrypt(Data,Pass), % SavePath
Msgbox, 64, Encryption Utility, '%FileName%.%Ext%' Encrypted!`nNew encrypted version is saved in the same folder as the original.
Run % "explorer.exe /select," SavePath
Return

Decrypt:
If FilePath = None
{
	Msgbox, 64, Encryption Utility, You did not select a file!
	Return
}

InputBox, Pass, Decrypt, Enter a password to use for decryption (if you set one).

If Errorlevel
{
	Msgbox, 64, Encryption Utility, You cancelled. Try again...
	Return
}

SplitPath, FilePath, FileName, Dir, Ext, FileNameNoExt
FileRead, Data, % FilePath
SavePath := Dir "\" FileNameNoExt "_Decrypted." Ext
FileDelete, % SavePath
FileAppend, % Decrypt(Data,Pass), % SavePath
Msgbox, 64, Encryption Utility, '%FileName%.%Ext%' Decrypted!`nNew Decrypted version is saved in the same folder as the original.
Run % "explorer.exe /select," SavePath
Return


Decrypt(Data,Pass) {
b := 0, j := 0, x := "0x"
VarSetCapacity(Result,StrLen(Data)//2)
Loop 256
a := A_Index - 1
,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1))
,sBox%a% := a
Loop 256
a := A_Index - 1
,b := b + sBox%a% + Key%a%  & 255
,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%)
Loop % StrLen(Data)//2
i := A_Index  & 255
,j := sBox%i% + j  & 255
,k := sBox%i% + sBox%j%  & 255
,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%)
,Result .= Chr((x . SubStr(Data,2*A_Index-1,2)) ^ sBox%k%)
Return Result
}

Encrypt(Data,Pass) {
Format := A_FormatInteger
SetFormat Integer, Hex
b := 0, j := 0
VarSetCapacity(Result,StrLen(Data)*2)
Loop 256
a := A_Index - 1
,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1))
,sBox%a% := a
Loop 256
a := A_Index - 1
,b := b + sBox%a% + Key%a%  & 255
,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%)
Loop Parse, Data
i := A_Index & 255
,j := sBox%i% + j  & 255
,k := sBox%i% + sBox%j%  & 255
,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%)
,Result .= SubStr(Asc(A_LoopField)^sBox%k%, -1, 2)
StringReplace Result, Result, x, 0, All
SetFormat Integer, %Format%
Return Result
}

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


Cephei1
  • Members
  • 396 posts
  • Last active: Jan 22 2014 08:19 PM
  • Joined: 04 Aug 2008
Lol how did you do it?

Ahk_L (Unicode 32-bit)


Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
You souldn't change the settings :)

<!-- m -->https://ahknet.autoh.../autosyntax.rar<!-- m --> >> ahk and ini file

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER


Cephei1
  • Members
  • 396 posts
  • Last active: Jan 22 2014 08:19 PM
  • Joined: 04 Aug 2008
I have now updated it and added the compiled and source link. Please read the first post.
Cephei1

Ahk_L (Unicode 32-bit)


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008
Is this script only for unicode.

Here are my results on Ansi 32bit autohotkey_L

Before Encryption...

I just whipped this up quickly, nothing major. It provides 128bit protection to text files. However, as many of you have requested, it can be redesigned (the GUI and it's operation) so that you don't need to save your data to a text file each time you want to encrypt it. A simple Edit box to enter data and a Text box to show the encrypted/decrypted data would be much more handy.


After Decryption...

W
ã²jX.*+1ÆK¦ˆ)GãG5Gñã'"?xÐ-¨"öWʧt†‹
S°=arìmwL YÙƒ5S?<y'È*5ÇòçtX-s^•iHÏ‘mF:CøÙ%Ã÷³èYl– ·†aê–bOœ'RiyOóã5 …àF…[kP¿


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

Klark92
  • Members
  • 870 posts
  • Last active: Dec 29 2015 09:47 PM
  • Joined: 19 Feb 2012
@ DataLife
this script can't encrypt the "Binary Zeros" .. so your text have that I think
or upload your text then I try to solve

I CAN PROTECT YOUR SCRIPT (ANTI-DECOMPILER by Klark92) (AHK_L*)(PM)
Klark92's Script2Exe Wizard
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER