Support Safari (not tested)

This commit is contained in:
Kagami Hiiragi 2014-12-18 23:54:27 +03:00
parent 77d753d84c
commit 6e4cb56a27
1 changed files with 7 additions and 3 deletions

View File

@ -7,16 +7,20 @@
*
* @module bitmessage/crypto.browser
*/
// FIXME(Kagami): Support webkit subtle prefix!
// TODO(Kagami): Try to support IE11.
"use strict";
require("es6-promise").polyfill();
var ripemd160 = require("ripemd160");
var assert = require("./utils").assert;
// Support `webkit` prefix for Safari (not tested yet).
// TODO(Kagami): Try to support IE11.
var subtle = window.crypto.subtle || window.crypto.webkitSubtle;
assert(subtle, "WebCryptoAPI is not supported");
exports.sha512 = function(buf) {
return window.crypto.subtle.digest({name: "SHA-512"}, buf).then(function(arr) {
return subtle.digest({name: "SHA-512"}, buf).then(function(arr) {
return new Buffer(new Uint8Array(arr));
});
};