<< Click to Display Table of Contents >> Navigation: 3. Script Language > Encryption and Hash Functions > Encryption and Hashing Commands |
MiniRobotLanguage (MRL)
GEC. Command
Get Encryption
Intention
Encrypts a string or a file, to a string or a file. And decrypts such a string or file.
The usage on string is simple:
' Encrypt Variable into Variable
GEC.e1|$$TXT|$$KEY|$$TXT
'This way you can save the result as file immediately.
' Decrypt Variable into file
GEC.do1|$$TXT|$$KEY|$$FIL
' Here we encrypt a file
GEC.efo1|$$FIL|$$KEY|$$FIL
' Here we decrypt a file
GEC.dfo1|$$FIL|$$KEY|$$FIL
' This example encrypts a file into a variable
GEC.ef1|$$FIL|$$KEY|$$TXT
For details see example 2 below.
File-size of string or file is been changed to a multiple of 8. Optimal size for the password is 16 bytes. Longer password size will internally be shortened to 16 Bytes.
GEC. has been enhanced in the update 1/2015.
In the previouse implemtation of GEC., Passwords wit ha length of less then 16 Bytes (128 Bit) have been autofilled with ASCII(32) (Space).
In the actual GEC.-Implementation this is been changed to a more difficult Bit-Pattern that is computed from the given Password.
Therefore, if you recompile "old Scripts" that have used short passwords, they may not be able to decrypt old data-files, until you fill the old Password with ASC 32.
Also there are many new Options with GEC. that make it to a simple to use - yet unbreakable Crypto-Construction Set.
Speed considerations:
On a typical test-system, a file with 17.8 MB is encrypted with lowest strenght in 0.3 seconds. The decryption of the same file takes about 0.2 seconds. Note that for most use-cases, this level is all you will ever need.
The same file is been encrypted with standard strength (140 Rounds) in about 1.9 seconds. The decryption for that file takes 1.7 seconds.
The same file is been encrypted with highest strength (level 9) in about 12.8 seconds. The decryption for that file takes 12.3 seconds.
Syntax
GEC.P1|P2|P3[|P4]
Parameter Explanation
P1 - VAR/Prototypes
P2 - VAR with the String or the Filename to process
P3 - VAR with Key to en-/decrypt
P4 - (optional) VAR with Filename or Variable for the result, if omitted, result goes to TOS
Prototypes must be lowercase letters like following:
f -input from file - if f is not specified, the Variable is been resolved to a string.
e - "Encrypt". If e is not specified the input is been decrypted.
p - Use "one Time Pad" encryption (XOR) after using the TEA-Encryption.
In this case P3 contains the "One Time Pad".
You can create "One Time Pads" using the STR.CHARS D etc. command.
When using the "p"- Option, the Passwort for the TEA-Encryption is taken
out of the "One Time Pad".
q - Additionally use a "Byte-Flood"-Algo. This will additionally confuse the resulting
Bit-Pattern.
o - output result to a file. if o is not specified, output is directed into the variable P3, or if none to the TOS.
k - kill-file. If specified, source-file is been deleted after encryption. If specified with variable, the variable is been cleared.
m - max Encryption. Multiply number of Rounds times 1000.
Specify this to use maximum strong encryption. If given, the normally used number of
rounds is multiplied by 1000.
s - "Scramble Result". If given, this option will scramble the result in a way that you will never get the same result twice.
If you use the "s" Option for encryption, you must also use the "s" Option for decryption also, else the result of the decryption will be useless.
For example:
m1 - normally 1 Round will then be 1000 Rounds.
m9 - 1024000 Rounds (don't worry its still very fast!
1-9 strength of encryption (if omitted, default = 140 Rounds).
Here are the details on the strength value:
0 - Encrypt with just 1 Round. This is for testing and learning purpose, do NOT use it for encryption. Unless you use other algos after this.
1 - (10 Rounds) is already above so called "weak encryption"
2 to 8: Multiply the number times 25 to get the number of rounds.
Example: 2 = 50 Rounds, 8 = 200 Rounds
9 - Use 1024 Rounds (maximum strength)
As we have complete diffusion after only 6 rounds, even the lowest Level of "1" is already above "weak encryption" and strong enough for non-professional use. The strongest level has 1024 Rounds.
Example
'******************************************************************
' GEC-Sample 1
'******************************************************************
' The following line contains the password
' for encryption and de-cryption
: $$KEY=My_Password
: $$FIL=?desktop\Mysecret.txt
: $$TXT=This text is going to be hidden!$crlf$Even this line is a secret!
FOR.$$MUC|1|18
VAR.$$TXT=$crlf$ $$TXT $crlf$ $$TXT
NEX.
LEN.$$TXT|$$SIZ
MBX.We are now going to encrypt a string of size: $$SIZ to a file on your desktop.$crlf$The filename is:$$FIL
VAR.$$TIM=#dtime#
' Encrypt Variable into file with highest strength
GEC.eo|$$TXT|$$KEY|$$FIL
MBX.The file (Size: $$SIZ) was successfully encrypted with high strength.$crlf$Take a look on it before we de-crypt it again.$crlf$ Time needed for encryption: #dsince# seconds.
' Now we decrypt the file from desktop to itself
VAR.$$TIM=#dtime#
GEC.dfo|$$FIL|$$KEY|$$FIL
MBX.The file was successfully decrypted.$crlf$Take a look on it before we encrypt it again.$crlf$Time needed for decryption: #dsince# seconds.
VAR.$$TIM=#dtime#
GEC.efo|$$FIL|$$KEY|$$FIL
MBX.The file (Size: $$SIZ) was successfully encrypted with high strength.$crlf$Take a look on it before we de-crypt it again.$crlf$ Time needed for encryption: #dsince# seconds.
VAR.$$TIM=#dtime#
GEC.dfo|$$FIL|$$KEY|$$FIL
MBX.The file was successfully decrypted.$crlf$Take a look on it before we encrypt it again.$crlf$Time needed for decryption: #dsince# seconds.
ENR.
'******************************************************************
' GEC-Sample 2
'******************************************************************
' The following line contains the password for
' encryption and de-cryption
: $$KEY=aaaaa
: $$FIL=?desktop\Mysecret.txt
: $$TXT=aaaaaaaaaaaaaaaaaaa
' Encrypt Variable into Variable
GEC.e1|$$TXT|$$KEY|$$TXT
MBX.The text was successfully encrypted.$crlf$+$$TXT
' Encrypt Variable into file with highest strength
GEC.do1|$$TXT|$$KEY|$$FIL
MBX.The text was successfully decrypted to file $crlf$ $$FIL.
GEC.efo1|$$FIL|$$KEY|$$FIL
MBX.The file was successfully encrypted.
GEC.dfo1|$$FIL|$$KEY|$$FIL
MBX.The file was successfully decrypted.
GEC.efo1|$$FIL|$$KEY|$$FIL
MBX.The file was successfully encrypted to File.
GEC.df1|$$FIL|$$KEY|$$TXT
MBX.The File was successfully decrypted to:$crlf$$$TXT.
ENR.
Remarks
GEC. is provided to enable you, to hide data, like Passwords and such, with a cryptographic algo, that is tested to make your data unreadable.
From a scientific standpoint, the use of GEC. together with the OTP (One-Time-Pad) Option "p", the result should be unbreakable.
For more Details see ! Smart Package Robot 's Encryption and Hashing Commands .
While giving the best we can provide, we can not take any responsibility for safety of your encrypted data. Computers get faster, science makes progress. There is no warranty that data being encrypted today can be seen as safe tomorrow.
Therefore use GEC. on your own risk.
Note that even if you specify the "k"-Option, which will delete a file after overwriting it 40 times with Byte-Patterns, the original file may under unknown circumstances still be undeleted by professional undelete experts, especially when it was on a SSD-Drive.
To use the encrypted characters in Chat-Programs or e-mail, do not forget to use the
STR.TEXT TO MIME before,
Of course the encoding must be reversed on the other side before decryption.
Limitations:
1. File-Size
The actual Implementation tries to load the complete file into Memory before applying the Encryption. Therefore Files with a size that exceeds the Systems RAM Capabilities can not be encrypted or decrypted.
In case there are File-Errors, an empty string is returned.
Please note that the smallest possible Encryption-Result is always 8 bytes or a multiple of 8 bytes. After Decryption the File/string will have its original size, that it the size it had before being encrypted.
2. Encryption Limitations:
TEA* - Tiny Encryption Algorhytmus
Stats of the TEA*-Encryption:
· Block Symmetric Feistel cipher.
· 128 bit key
· Encrypts 64 bits at a time
· Highly resistant to differential cyptanalysis
· Achieves complete diffusion after 6 rounds
- one bit difference in plaintext will cause approximately 32 bit differences in ciphertext
The used TEA*-Encryption is very fast and can be seen as safe for normal "house use". From seven "Encryption-Rounds" up it is already above so called "weak Encryption". As each "Prototype" value counts for 25 Encryption rounds, this is already the case for our lowest Encryption level (level "1"). Because even in level "1" we make 10 internal "Encryption Rounds".
While being already safe for "house use", it may be vulnerable to professionals via "related-key attacks". To prevent this, it should be used with keys that are generated by a strong Random Number Generator, or by a source of bits that are sufficiently uncorrelated (such as the output of a hash function).
Even with a non-perfect key, the prototype "4" ( internally= 100 Encryption rounds) should cure most sins, while still being very fast.
For more in Detail mathematical information see "Block Ciphers and Cryptanalysis".
3. CPU-Limitations
For best possible Speed, MMX was used. Therefore the results on "non-MMX CPU's are unpredictable.
* Developed by David Wheeler and Roger Needham at Cambridge University
See also: