2014-12-13 19:56:14 +01:00
|
|
|
/**
|
2015-01-03 11:29:22 +01:00
|
|
|
* Browser implementation of platform-specific routines.
|
2014-12-13 19:56:14 +01:00
|
|
|
*/
|
2014-12-14 10:24:35 +01:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2015-01-03 15:52:27 +01:00
|
|
|
var createHash = require("sha.js");
|
2014-12-18 17:47:18 +01:00
|
|
|
var ripemd160 = require("ripemd160");
|
2014-12-18 21:54:27 +01:00
|
|
|
|
2014-12-14 10:24:35 +01:00
|
|
|
exports.sha512 = function(buf) {
|
2015-01-03 15:52:27 +01:00
|
|
|
return createHash("sha512").update(buf).digest();
|
2014-12-14 10:24:35 +01:00
|
|
|
};
|
2014-12-18 17:47:18 +01:00
|
|
|
|
2014-12-19 13:34:33 +01:00
|
|
|
exports.sha256 = function(buf) {
|
2015-01-03 15:52:27 +01:00
|
|
|
return createHash("sha256").update(buf).digest();
|
2014-12-19 13:34:33 +01:00
|
|
|
};
|
|
|
|
|
2015-01-03 15:52:27 +01:00
|
|
|
exports.ripemd160 = ripemd160;
|
2014-12-26 18:17:01 +01:00
|
|
|
|
|
|
|
exports.randomBytes = function(size) {
|
|
|
|
var arr = new Uint8Array(size);
|
|
|
|
window.crypto.getRandomValues(arr);
|
|
|
|
return new Buffer(arr);
|
|
|
|
};
|