To encrypt a file, drag it over the attached executable; filename.enc will be generated
To decrypt a file, drag filename.enc over the executable.
The password should be around 12 valid characters long. Spaces, tabs etc get ignored. A-Z, a-z, 0-9, /#*$&:+-?\ are valid password elements.
Is it safe? Use at your own risk, and never forget the password - I won't be able to help you :cool:
The password generates two seeds for use in two independent and pretty good PRNGs. The password also generates two offsets that are used to insert several hundred random bytes at the start and the end of the file. An attacker would have to...
- guess a dword value from the original (which is not impossible, e.g. PKxx for zip files)
- find two independent PRNG series with a period of almost 4GB that produce this dword
- do that several hundred times at the start of the *.enc file, because the position of the PKxx is not known.
IMHO it is pretty safe, but again: use at your own risk. Building requires MasmBasic 11 July 2020 (http://masm32.com/board/index.php?topic=94.0) :cool:
Note that the *.enc file cannot be compressed. Below a screenshot from an attempt to zip the *.enc file. While the original file compresses quite well (almost a factor 5), the encrypted version is virtually uncompressible. It is therefore recommended to zip large files first, then encrypt them.
include \masm32\MasmBasic\MasmBasic.inc
Init
Let esi=Qtrim$(CL$()) ; get the file from the commandline
.if Exist(esi)
Let edi=Input$("Password: ", "Assembly is fun!") ; 12 chars will be used (blanks and ! ignored)
.if dword ptr [esi+Len(esi)-4]==Mirror$(".enc") ; encrypted file
Decrypt esi, edi ; decrypt...
ShEx eax ; ... and show
.else
Encrypt esi, edi
PrintLine "Encoded as ", eax
.endif
.else
PrintLine "No commandline found: ", esi
.endif
EndOfCode
P.S.: It's Assembly, i.e. fast - a 20MB file encrypts and decrypts in about 150 milliseconds on my trusty old Core i5 :tongue:
Update: With MasmBasic of 11 July 20 V2 (http://masm32.com/board/index.php?topic=94.0), Encrypt and Decrypt do not change the file's time stamp, unless you specify MbCryptTS=0
Is there a way to change .enc to .xyz without messing inc file
Try modifying the line :
.if dword ptr [esi+Len(esi)-4]==Mirror$(".enc")
to
.if dword ptr [esi+Len(esi)-4]==Mirror$(".xyz")
Without modifying the source code, the application cannot easily identify the encrypted files : the file extension .enc , .xyz or another one should be defined in the source code. An alternative for you is to develop the project to read the registry storing the file externsion of the encrypted files.
Quote from: Vortex on November 03, 2024, 10:13:17 PMTry modifying the line :
Code Select Expand
.if dword ptr [esi+Len(esi)-4]==Mirror$(".enc")
to
Code Select Expand
.if dword ptr [esi+Len(esi)-4]==Mirror$(".xyz")
This only modifies the file that the Decrypt function will handle with
Not changing the output of Encrypt function still .enc
and i cant change the password ?
Hi 3bas_Elhendy,
Did you read correctly my reply?
Quote from: Vortex on November 03, 2024, 10:36:02 PMHi 3bas_Elhendy,
Did you read correctly my reply?
sorry about that my English is bad
so i remove that line or what
.if dword ptr [esi+Len(esi)-4]==Mirror$(".enc")
Hi Hi 3bas_Elhendy,
Simply change that line to :
.if dword ptr [esi+Len(esi)-4]==Mirror$(".xyz")
The extension .enc replaced by .xyz