bitmessage-js/lib/platform.browser.js
Kagami Hiiragi 2dd9efd1a6 Use hash.js impl of SHA-256 and RIPEMD-160
Because it's already required by elliptic
2015-01-05 16:34:52 +03:00

27 lines
548 B
JavaScript

/**
* Browser implementation of platform-specific routines.
*/
"use strict";
var createHash = require("sha.js");
var hash = require("hash.js");
exports.sha512 = function(buf) {
return createHash("sha512").update(buf).digest();
};
exports.sha256 = function(buf) {
return hash.sha256().update(buf).digest();
};
exports.ripemd160 = function(buf) {
return hash.ripemd160().update(buf).digest();
};
exports.randomBytes = function(size) {
var arr = new Uint8Array(size);
window.crypto.getRandomValues(arr);
return new Buffer(arr);
};