API Docs

Module for hashing and encoding operations

Properties

This module has no properties.

Methods

hs.hash.base64Encode(data) -> string

Encode a string to base64
hs.hash.base64Encode(data) -> string
Name Type Description
data string The string to encode
string
Base64 encoded string
console.log(hs.hash.base64Encode("Hello"))

hs.hash.base64Decode(data) -> string

Decode a base64 string
hs.hash.base64Decode(data) -> string
Name Type Description
data string The base64 string to decode
string
Decoded string, or nil if the input is invalid
console.log(hs.hash.base64Decode("SGVsbG8="))

hs.hash.md5(data) -> string

Generate MD5 hash of a string
hs.hash.md5(data) -> string
Name Type Description
data string The string to hash
string
Hexadecimal MD5 hash
console.log(hs.hash.md5("hello"))

hs.hash.sha1(data) -> string

Generate SHA1 hash of a string
hs.hash.sha1(data) -> string
Name Type Description
data string The string to hash
string
Hexadecimal SHA1 hash
console.log(hs.hash.sha1("hello"))

hs.hash.sha256(data) -> string

Generate SHA256 hash of a string
hs.hash.sha256(data) -> string
Name Type Description
data string The string to hash
string
Hexadecimal SHA256 hash
console.log(hs.hash.sha256("hello"))

hs.hash.sha512(data) -> string

Generate SHA512 hash of a string
hs.hash.sha512(data) -> string
Name Type Description
data string The string to hash
string
Hexadecimal SHA512 hash
console.log(hs.hash.sha512("hello"))

hs.hash.hmacMD5(key, data) -> string

Generate HMAC-MD5 of a string with a key
hs.hash.hmacMD5(key, data) -> string
Name Type Description
key string The secret key
data string The data to authenticate
string
Hexadecimal HMAC-MD5
console.log(hs.hash.hmacMD5("secret", "hello"))

hs.hash.hmacSHA1(key, data) -> string

Generate HMAC-SHA1 of a string with a key
hs.hash.hmacSHA1(key, data) -> string
Name Type Description
key string The secret key
data string The data to authenticate
string
Hexadecimal HMAC-SHA1
console.log(hs.hash.hmacSHA1("secret", "hello"))

hs.hash.hmacSHA256(key, data) -> string

Generate HMAC-SHA256 of a string with a key
hs.hash.hmacSHA256(key, data) -> string
Name Type Description
key string The secret key
data string The data to authenticate
string
Hexadecimal HMAC-SHA256
console.log(hs.hash.hmacSHA256("secret", "hello"))

hs.hash.hmacSHA512(key, data) -> string

Generate HMAC-SHA512 of a string with a key
hs.hash.hmacSHA512(key, data) -> string
Name Type Description
key string The secret key
data string The data to authenticate
string
Hexadecimal HMAC-SHA512
console.log(hs.hash.hmacSHA512("secret", "hello"))