Skip to main content

Encr_MakeDigest (function reference)

By April 20, 2023April 25th, 2023Online Help, Troi Encryptor Plug-in
Troi Encryptor Plug-in for FileMaker Pro

Encr_MakeDigest

Generates a MD5 or SHA digest.

SyntaxFunction badge

Encr_MakeDigest ( switches ; text )

Parameters

switches determines the behavior of the function
text the text to calculate the digest of

Switches

Switches can be one of this:

-md5 use the MD5 algorithm
-sha1 use the SHA-1 algorithm
-sha256 use the SHA-256 algorithm

You can also add one or more of the switches below:

-hex (default) output as a hex dump. This is the default for a "normal" digest as opposed to a digital signature.
-colons add colons between the result
-Encoding=UTF8 this will encode higher Unicode to UTF8 first, before calculating the digest. This is useful for for example Russian or Chinese texts.
-DigestCompatibleWithv30 generate the (incorrect) digests of v3.0, which only differ for digests of text bigger than 32000 characters.

Returned Result

Data type returned

Text

Result

the digest, which is a string of bits.
MD5: a digest of 128 bits, formatted as 32 characters
SHA-1: a digest of 160 bits, formatted as 40 characters
SHA-256: a digest of 256 bits, formatted as 64 characters

The characters are all lower ASCII and therefore safe to send across internet.

Originated in

Troi Encryptor Plug-in 1.2

Compatibility

FileMaker Pro 16 to FileMaker Pro 2023

Considerations

Troi Encryptor Plug-in 6.0 adds the new switch -SHA256
What is MD5, SHA-1 and SHA256?

MD5: MD5 was developed by Prof. Rivest in 1994. Its 128 bit (16 characters) message digest makes it a faster implementation than SHA-1, but is no longer considered safe.

SHA-1 + SHA256 : The Secure Hash Algorithm (SHA) was developed by NIST and is specified in the Secure Hash Standard (SHS, FIPS 180). SHA-1 produces a 160-bit (20 bytes) message digest. SHA256 even has 256 bits (or 32 bytes) length. This larger digest size makes it stronger against brute force attacks.

Note that MD5 is no longer considered collision-free/unique. If possible use SHA-1. You can find more info on this here:
here.

Please note that we fixed a bug in v3.0.1 which was introduced in v3.0: when creating a MD5 digest an incorrect digest would be returned for texts bigger than 32000 characters. We have added a switch “-DigestsCompatibleWithv30” so you can generate the (incorrect) digests of v3.0 if needed.

Example

Encr_MakeDigest ( "-md5" ; 
		"Here is a sample text that you can see the digest of." )

gives this result: “937ddb8fcd1c7d947aa3bb66789e82e8”

If you add the “-colons” switch, the result is:
“93:7d:db:8f:cd:1c:7d:94:7a:a3:bb:66:78:9e:82:e8”

If you use “-sha1” as switch, the result is:
“0e987e2893ba31b7b724d53991bf7b3d6bdabb75”

If you use “-sha1 -colons” as switches, the result is:
“0e:98:7e:28:93:ba:31:b7:b7:24:d5:39:91:bf:7b:3d:6b:da:bb:75”

Example 2

You can use this function to check if (the meaning of) a text was not changed, by adding the signature to the message.

Send Message [ message & "¶MD5 Digest = " & Encr_MakeDigest ( "-md5" ;  message ) ]

At the receiving end you need these fields:

signaturePos		= Position (messageReceived ; "¶MD5 Digest = " ; 1 ; 1 )
messageClean   		= Left (messageReceived ; signaturePos )
signatureReceived  	= Middle ( messageReceived ;  signaturePos + 12 ; 
				Length ( messageReceived ) )
messageOK  		= Encr_MakeDigest ( "-md5" ; messageClean ) = signatureReceived

Used in example file

MakeDigest.fmp12

Related functionsFunction badge

Encr_Checksum
Encr_TextSignature

Related topics

Troi Encryptor Plug-in online help (overview)


Online Help Page for Troi Encryptor Plug-in for 16 to 2023 –> Encr_MakeDigest (encrp5000) 2023-0425 15:57:38