Crypto Module

Simple, fast crypto service. Import

import crypto from 'crypto';

Methods

md5(string) md5Hmac(string, string) sha1(string) sha1Hmac(string, string) sha256(string) sha256Hmac(string, string) sha512(string) sha512Hmac(string, string) rsa.encrypt(apiKey, payload, outputEncoding=buffer, inputEncoding=utf8) rsa.decrypt(apiKey, payload, outputEncoding=utf8)

md5(string)

Arguments

  • value (String) string to hash

Returns

  • value (String) hash value

md5Hmac(string, string)

Arguments

  • secret (String) secret key

  • value (String) string to hash

Returns

  • value (String) hash value

sha1(string)

Arguments

  • value (String) string to hash

Returns

  • value (String) hash value

sha1Hmac(string, string)

Arguments

  • secret (String) secret key

  • value (String) string to hash

Returns

  • value (String) hash value

sha256(string)

Arguments

  • value (String) string to hash

Returns

  • value (String) hash value

sha256Hmac(string, string)

Arguments

  • secret (String) secret key

  • value (String) string to hash

Returns

  • value (String) hash value

sha512(string)

Arguments

  • value (String) string to hash

Returns

  • value (String) hash value

sha512Hmac(string, string)

Arguments

  • secret (String) secret key

  • value (String) string to hash

Returns

  • value (String) hash value

rsa.encrypt(apiKey, payload, outputEncoding=buffer, inputEncoding=utf8)

Encrypt a JSON object or a string using an app's RSA public key

Arguments

  • apiKey (String) The app api key that holds the key pair

  • payload (String|Object) string or JSON object to encrypt

  • outputEncoding (String=buffer) Support output encodings are hex, base64, buffer and binary

  • inputEncoding (String=utf8) Supported input encodings are hex, base64 and utf8

Returns

  • value (Buffer|String) encrypted value

rsa.decrypt(apiKey, payload, outputEncoding=utf8)

Decrypt a buffer or base64 encoded string app's RSA private key

Arguments

  • apiKey (String) The app api key that holds the key pair

  • payload (String|Buffer) string or buffer to decrypt

  • outputEncoding (String=utf8) Support output encodings are hex, base64, buffer, binary, utf8 and json. If json is specified, decrypt will parse the resulting string..

Returns

  • value (String|Object) decrypted value

Examples

Crypto Example

Crypto Example Response

Last updated

Was this helpful?