Timo Hocker 270a64aea4
Some checks failed
continuous-integration/drone/push Build is failing
fix drone config
2020-08-07 08:11:51 +02:00
2020-05-15 16:28:17 +02:00
2020-08-07 08:11:51 +02:00
fix
2020-05-06 10:08:28 +02:00
2020-05-15 16:28:17 +02:00
2020-05-15 16:28:17 +02:00
2020-05-15 16:28:17 +02:00
fix
2020-07-19 14:19:54 +02:00
2020-05-15 16:28:17 +02:00
2020-05-15 16:28:17 +02:00
2020-07-19 14:59:53 +02:00
fix
2020-05-17 18:56:46 +02:00
2020-05-15 16:28:17 +02:00
2020-08-04 12:47:21 +02:00

@sapphirecode/crypto-helper

version: 1.1.x

simple functions for cryptography

Installation

npm:

npm i --save @sapphirecode/crypto-helper

yarn:

yarn add @sapphirecode/crypto-helper

Usage

const crypto = require('@sapphirecode/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 info = crypto.get_signature_info(signed); // returns an object with iat (issued at), key_info and data
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.

// encryption
const enc = crypto.encrypt_aes('foo', 'bar');
const dec = crypto.decrypt_aes(enc, 'bar');

License

MIT © Timo Hocker timo@scode.ovh

Description
No description provided
Readme 612 KiB
Languages
JavaScript 100%