2014-12-13 19:56:14 +01:00
|
|
|
/**
|
|
|
|
* Node.js version of the crypto for Bitmessage JS implementation.
|
2014-12-18 17:47:18 +01:00
|
|
|
* @module bitmessage/crypto
|
2014-12-13 19:56:14 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2014-12-18 17:47:18 +01:00
|
|
|
require("es6-promise").polyfill();
|
2014-12-13 19:56:14 +01:00
|
|
|
var crypto = require("crypto");
|
|
|
|
|
|
|
|
exports.sha512 = function(buf) {
|
|
|
|
var hash = crypto.createHash("sha512");
|
|
|
|
hash.update(buf);
|
|
|
|
return Promise.resolve(hash.digest());
|
|
|
|
};
|
2014-12-18 17:47:18 +01:00
|
|
|
|
2014-12-19 13:34:33 +01:00
|
|
|
exports.sha256 = function(buf) {
|
|
|
|
var hash = crypto.createHash("sha256");
|
|
|
|
hash.update(buf);
|
|
|
|
return Promise.resolve(hash.digest());
|
|
|
|
};
|
|
|
|
|
2014-12-18 17:47:18 +01:00
|
|
|
exports.ripemd160 = function(buf) {
|
|
|
|
var hash = crypto.createHash("ripemd160");
|
|
|
|
hash.update(buf);
|
|
|
|
return Promise.resolve(hash.digest());
|
|
|
|
};
|