The scoped GlideDigest class provides methods for creating a message digest from strings or input streams using MD5, SHA1, or SHA256 hash algorithms.

GlideDigest - GlideDigest()

Creates an instance of scoped GlideDigest.

Table 1. Parameters
Name Type Description
None

GlideDigest - getMD5Base64(String source)

Creates a message digest from a string using the MD5 algorithm. The output string is in Base64.

Table 2. Parameters
Name Type Description
source String The source string.
Table 3. Returns
Type Description
String The message digest.

Example

var inputString = "Her molasses flowed slowly down the hill.";
var digest = new GlideDigest();
gs.info(digest.getMD5Base64(inputString));

GlideDigest - getMD5Base64FromInputStream( GlideScriptableInputStream inputStream)

Creates a message digest from an input stream using the MD5 algorithm. The output string is in Base64.

Table 4. Parameters
Name Type Description
inputStream GlideScriptableInputStream The source input stream.
Table 5. Returns
Type Description
String The message digest.

Example

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysID);
var digest = new GlideDigest();
gs.info(digest.getMD5Base64FromInputStream(inputStream));

GlideDigest - getMD5Hex(String source)

Creates a message digest from a string using the MD5 algorithm. The output string is in hexadecimal.

Table 6. Parameters
Name Type Description
source String The source string.
Table 7. Returns
Type Description
String The message digest.

Example

var inputString = "Her molasses flowed slowly down the hill.";
var digest = new GlideDigest();
gs.info(digest.getMD5Hex(inputString));

GlideDigest - getMD5HexFromInputStream( GlideScriptableInputStream inputStream)

Creates a message digest from an input stream using the MD5 algorithm. The output string is in hexadecimal.

Table 8. Parameters
Name Type Description
inputStream GlideScriptableInputStream The source input stream.
Table 9. Returns
Type Description
String The message digest.

Example

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysID);
var digest = new GlideDigest();
gs.info(digest.getMD5HexFromInputStream(inputStream));

GlideDigest - getSHA1Base64(String source)

Creates a message digest from a string using the SHA1 algorithm. The output string is in Base64.

Table 10. Parameters
Name Type Description
source String The source string.
Table 11. Returns
Type Description
String The message digest.

Example

var inputString = "Her molasses flowed slowly down the hill.";
var digest = new GlideDigest();
gs.info(digest.getSHA1Base64(inputString));

GlideDigest - getSHA1Base64FromInputStream( GlideScriptableInputStream inputStream)

Creates a message digest from an input stream using the SHA1 algorithm. The output string is in Base64.

Table 12. Parameters
Name Type Description
inputStream GlideScriptableInputStream The source input stream.
Table 13. Returns
Type Description
String The message digest.

Example

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysID);
var digest = new GlideDigest();
gs.info(digest.getSHA1Base64FromInputStream(inputStream));

GlideDigest - getSHA1Hex(String source)

Creates a message digest from a string using the SHA1 algorithm. The output string is in hexadecimal.

Table 14. Parameters
Name Type Description
source String The source string.
Table 15. Returns
Type Description
String The message digest.

Example

var inputString = "Her molasses flowed slowly down the hill.";
var digest = new GlideDigest();
gs.info(digest.getSHA1Hex(inputString));

GlideDigest - getSHA1HexFromInputStream( GlideScriptableInputStream inputStream)

Creates a message digest from an input stream using the SHA1 algorithm. The output string is in hexadecimal.

Table 16. Parameters
Name Type Description
inputStream GlideScriptableInputStream The source input stream.
Table 17. Returns
Type Description
String The message digest.

Example

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysID);
var digest = new GlideDigest();
gs.info(digest.getSHA1HexFromInputStream(inputStream));

GlideDigest - getSHA256Base64(String source)

Creates a message digest from a string using the SHA256 algorithm. The output string is in Base64.

Table 18. Parameters
Name Type Description
source String The source string.
Table 19. Returns
Type Description
String The message digest.

Example

var inputString = "Her molasses flowed slowly down the hill.";
var digest = new GlideDigest();
gs.info(digest.getSHA256Base64(inputString));

GlideDigest - getSHA256Base64FromInputStream( GlideScriptableInputStream inputStream)

Creates a message digest from an input stream using the SHA256 algorithm. The output string is in Base64.

Table 20. Parameters
Name Type Description
inputStream GlideScriptableInputStream The source input stream.
Table 21. Returns
Type Description
String The message digest.

Example

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysID);
var digest = new GlideDigest();
gs.info(digest.getSHA256Base64FromInputStream(inputStream));

GlideDigest - getSHA256Hex(String source)

Creates a message digest from a string using the SHA256 algorithm. The output string is in hexadecimal.

Table 22. Parameters
Name Type Description
source String The source string.
Table 23. Returns
Type Description
String The message digest.

Example

var inputString = "Her molasses flowed slowly down the hill.";
var digest = new GlideDigest();
gs.info(digest.getSHA256Hex(inputString));

GlideDigest - getSHA256HexFromInputStream( GlideScriptableInputStream inputStream)

Creates a message digest from an input stream using the SHA256 algorithm. The output string is in hexadecimal.

Table 24. Parameters
Name Type Description
inputStream GlideScriptableInputStream The source input stream.
Table 25. Returns
Type Description
String The message digest.

Example

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysID);
var digest = new GlideDigest();
gs.info(digest.getSHA256HexFromInputStream(inputStream));