MosCrypto

The MosCrypto object provides access to some cryptographic functions.

Methods

Name

Description

toBase64(byteArray)

Converts input byte array into output byte array in Base64 format.

fromBase64(byteArray)

Converts input byte array in Base64 format into source byte array.

toBase64String(byteArray)

Converts input byte array into Base64 string.

getSha1Hash(byteArray)

Returns SHA1 hash for input byte array as byte array.

getSha256Hash(byteArray)

Returns SHA256 hash for input byte array as byte array.

getSha384Hash(byteArray)

Returns SHA384 hash for input byte array as byte array.

getSha512Hash(byteArray)

Returns SHA512 hash for input byte array as byte array.

getMd5Hash(byteArray)

Returns MD5 hash for input byte array as byte array.

bytesToHex(byteArray)

Converts input byte array into HEX string.

getGuidAsBytes()

Generates GUID as byte array.

getGuidAsString()

Generates GUID as string formatted as XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.

encodeUri(keys, values)

Encodes (key/value) pairs for URI.

The following example shows a script that converts the source string to a Base64 string:

var input = 'input string';
var bytes = MosText.utf8ToBytes(input);
var base64 = MosCrypto.toBase64String(bytes);

Last updated