crypto-helper/lib/hashing.js
Timo Hocker ecd0195aee
All checks were successful
continuous-integration/drone/push Build is passing
refactoring, asymmetric signatures and encryption
2021-01-06 15:13:44 +01:00

35 lines
593 B
JavaScript

'use strict';
const crypto = require ('crypto');
/**
* creates a sha256 hash
*
* @param {any} data input
* @returns {string} hash
*/
function checksum (data) {
const md = crypto.createHash ('sha256');
md.update (String (data));
return md.digest ('hex');
}
/**
* creates a sha512 hash
*
* @param {string} str string input
* @param {string} salt salt
* @returns {string} salt
*/
function hash_sha512 (str, salt) {
const md = crypto.createHash ('sha512');
md.update (str);
md.update (salt);
return md.digest ('hex');
}
module.exports = {
hash_sha512,
checksum
};