Support Safari (not tested)

This commit is contained in:
Kagami Hiiragi 2014-12-18 23:54:27 +03:00
parent 77d753d84c
commit 6e4cb56a27

View File

@ -7,16 +7,20 @@
* *
* @module bitmessage/crypto.browser * @module bitmessage/crypto.browser
*/ */
// FIXME(Kagami): Support webkit subtle prefix!
// TODO(Kagami): Try to support IE11.
"use strict"; "use strict";
require("es6-promise").polyfill(); require("es6-promise").polyfill();
var ripemd160 = require("ripemd160"); 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) { 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)); return new Buffer(new Uint8Array(arr));
}); });
}; };