<< Click to Display Table of Contents >> Navigation: 3. Script Language > Encryption and Hash Functions > Encryption and Hashing Commands |
MiniRobotLanguage (MRL)
SHA. Command
Get Message Digest SHA I from String or File
Intention
This command returns the checksum of a string or a file. If you are not sure what a checksum is, or what it is good for, read this WEB-Link: Checksum.
Using SHA. you can currently choose between:
• SHA Details SHA
• MD5 Details MD5
Usage is very simple:
' Name and Path of the file
$$FIL=?desktop\MyFile.exe
SHA.$$FIL
' Display result
DBP.$$000
You can use a variable instead of the TOS:
' Name and Path of the file
$$FIL=?desktop\MyFile.exe
' $$RES will contain the SHA checksum
SHA.$$FIL|$$RES
' Display result
DBP.$$RES
If you prefer to get the MD4 checksum:
' Name and Path of the file
$$FIL=?desktop\MyFile.exe
' $$RES will contain the SHA checksum
SHA.$$FIL|$$RES|m
' Display result
DBP.$$RES
There are some more built in Options that influence the outlook of the result. You can:
• make the result string uppercase (use U in P3 )
• make the result string lowercase (use L in P3 )
• choose to have spaces for better readability when using SHA I, like this:
EC91328073 A651B13403 BA5B2D9730 861F312F88
• choose the MD5 Algo instead, specify "M" as P3
• Prefix P1 with the < Sign. In this case the String will be taken as Binary Data, instead of as Filename
Syntax
SHA.P1[|P2][|P3]
Parameter Explanation
P1 - VAR, Filename or String to calculate the checksum for. If the first letter is "<" then
input is taken from following variable using binary, one time resolution.
Otherwise P1 is taken as a filename/path for file that should be loaded
and processed.
P2 - (optional) - VAR for Return value. If omitted, TOS is used.
P3 - (optional) - any combination of these letters:
M - use the MD5 checksum. Result is a string of length 32.
L - Lowercase Result
U - Uppercase Result
S - Insert Spaces for better readability into SHA I Output.
This flag has no influence on the MD5 output.
Example
' Load the file and calculate SHA I checksum
$$FIL=?pfad\Sha1.exe
SHA.$$FIL|$$RES|s
DBP.$$RES
ENR.
Remarks
-
Limitations:
Possible maximum file-Size is limited by System RAM, and generally to a maximum of 2 GB (32 bit).
See also: