Commit 4f8b5a40 authored by JC Brand's avatar JC Brand

Use built-in crypto instead of CryptoJS

parent 11cc41d3
......@@ -5,10 +5,10 @@
// Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) {
define(["converse-core", "crypto", "templates/vcard.html"], factory);
}(this, function (converse, CryptoJS, tpl_vcard) {
define(["converse-core", "templates/vcard.html"], factory);
}(this, function (converse, tpl_vcard) {
"use strict";
const { Backbone, Promise, Strophe, SHA1, _, $iq, $build, b64_sha1, moment, sizzle } = converse.env;
const { Backbone, Promise, Strophe, _, $iq, $build, b64_sha1, moment, sizzle } = converse.env;
const u = converse.env.utils;
......@@ -74,11 +74,14 @@
};
}
if (result.image) {
const word_array_from_b64 = CryptoJS.enc.Base64.parse(result['image']);
result['image_hash'] = CryptoJS.SHA1(word_array_from_b64).toString()
}
if (callback) {
callback(result);
const buffer = u.base64ToArrayBuffer(result['image']);
crypto.subtle.digest('SHA-1', buffer)
.then(ab => {
result['image_hash'] = u.arrayBufferToHex(ab);
if (callback) callback(result);
});
} else {
if (callback) callback(result);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment