Encr_MakeDigest (function reference)

By February 1, 2019 February 12th, 2019 Online Help, Troi Encryptor Plug-in
Troi Encryptor Plug-in for FileMaker Pro

Encr_MakeDigest

Generates a MD5 or SHA1 digest.

SyntaxFunction badge

Encr_MakeDigest ( switches ; text )

Parameters

switchesdetermines the behavior of the function
textthe text to calculate the digest of

Switches

Switches can be one of this:

-md5use the MD5 algorithm
-sha1use the SHA-1 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.
-colonsadd colons between the result
-Encoding=UTF8this will encode higher Unicode to UTF8 first, before calculating the digest. This is useful for for example Russian or Chinese texts.
-DigestCompatibleWithv30generate 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

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

Originated in

Troi Encryptor Plug-in 1.2

Compatibility

FileMaker Pro 14 to 17

Considerations

What is MD5 and SHA-1?

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

SHA-1: 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 characters) message digest. 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:
http://www.mscs.dal.ca/~selinger/md5collision/

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

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 14 to 17 –> Encr_MakeDigest (encrp5000) 2019-0212 17:37:50