bitmessage-js/lib/platform.browser.js
Kagami Hiiragi 591134bd9a Fix hashes
2015-01-05 16:41:34 +03:00

27 lines
572 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 new Buffer(hash.sha256().update(buf).digest());
};
exports.ripemd160 = function(buf) {
return new Buffer(hash.ripemd160().update(buf).digest());
};
exports.randomBytes = function(size) {
var arr = new Uint8Array(size);
window.crypto.getRandomValues(arr);
return new Buffer(arr);
};