Cryptography and Checksum Functions

These functions are exported by the KS module.

AES

Data := AES(Value, Key , Decrypt := false)

Encrypts Value with the AES algorithm and returns a Buffer. If Decrypt is non-zero, decrypts the supplied data instead.

Hash Functions

Digest := MD5(Value)
Digest := SHA1(Value)
Digest := SHA256(Value)
Digest := SHA384(Value)
Digest := SHA512(Value)

Returns a hexadecimal digest. The result lengths are 32, 40, 64, 96 and 128 characters respectively.

Security warning: MD5 and SHA-1 are unsuitable for collision-resistant security uses. Use SHA-256 or stronger unless compatibility requires an older digest.

CRC32

Checksum := CRC32(Value)

Returns the CRC32 polynomial of Value as an integer. CRC32 detects accidental corruption; it is not a cryptographic integrity check.

SecureRandom

Value := SecureRandom(Min, Max)

Returns a cryptographically secure random number. If both bounds are integers, the result is an integer; if either is floating-point, the result uses floating-point bounds. Omit both to use the implementation's full default numeric range.

For non-security uses where speed is preferred, use Random.