| 12345678910111213141516171819202122232425 |
- const crypto = require('crypto');
- const fs = require('fs');
- const HASH = 'sha256';
- const DIGEST = 'base64url';
- function cryptoFile(path) {
- return crypto.createHash(HASH).update(fs.readFileSync(path)).digest(DIGEST);
- }
- function cryptoString(input) {
- return crypto.createHash(HASH).update(input).digest(DIGEST);
- }
- function publicKey(priv) {
- return cryptoString(priv).substr(0, 24);
- }
- module.exports = {
- file: cryptoFile,
- string: cryptoString,
- publicKey: publicKey
- }
|