shardus-crypto-web
Web crypto utilities as used by the Shardus project. Provides basic cryptography functions utilizing libsodium, with a simple API:
const crypto = require('shardus-crypto-web')
await crypto.initialize('64f152869ca2d473e4ba64ab53f49ccdb2edae22da192c126850970e788af347')
crypto.stringify(obj)
crypto.randomBytes([bytes])
crypto.hash(input [, fmt])
crypto.hashObj(obj [, removeSign])
crypto.generateKeypair()
crypto.sign(input, sk)
crypto.signObj(obj, sk, pk)
crypto.verify(input, sig, pk)
crypto.verifyObj(obj)
Install
npm install gitlab:Shardus/shardus-crypto-web
Use
const crypto = require('shardus-crypto-web')
(async () => {
await crypto.initialize('64f152869ca2d473e4ba64ab53f49ccdb2edae22da192c126850970e788af347')
let msg = crypto.hash('Hello world!')
console.log(msg)
})()