bitmessage-js/lib/platform.browser.js
Kagami Hiiragi bf8b663c5d Do not use promises in crypto
Because sha.js is faster than WebCryptoAPI for POW.
2015-01-03 17:52:27 +03:00

25 lines
506 B
JavaScript

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