From 1cb8f9b9854e3886ef3077a5780ac52b2c9b5935 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Fri, 6 Mar 2020 08:40:58 +0100 Subject: [PATCH] add readme --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..97ad613 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Crypto Helper + +Helper functions for cryptography + +## Usage + +```js +const crypto = require('@scode/crypto-helper'); + +const rand_hex = crypto.random_hex(16); // outputs 16 byte random hex +const rand_salt = crypto.create_salt(); // same as random_hex, but with fixed length of 32 bytes +const random_string = crypto.random_string(16) // output 16 character long random string +const hash = crypto.hash_sha512(random_string, random_hex); // returns sha 512 hex +const check = crypto.checksum('foo'); // returns a sha 256 hex + +// jwt like object signing +const signed = crypto.sign_object({foo: 'bar'}, 'secret'); +const dec = crypto.decode_signed(signed); // decode a signed object without verifying the signature +const ver = crypto.verify_signature(signed, 'secret', 10000); // verifies the signature and returns the contents. the timeout is in milliseconds and optional, timing will be ignored if omitted. +```