Use built-in crypto instead of CryptoJS
This commit is contained in:
parent
11cc41d3a3
commit
4f8b5a4022
@ -5,10 +5,10 @@
|
|||||||
// Licensed under the Mozilla Public License (MPLv2)
|
// Licensed under the Mozilla Public License (MPLv2)
|
||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define(["converse-core", "crypto", "templates/vcard.html"], factory);
|
define(["converse-core", "templates/vcard.html"], factory);
|
||||||
}(this, function (converse, CryptoJS, tpl_vcard) {
|
}(this, function (converse, tpl_vcard) {
|
||||||
"use strict";
|
"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;
|
const u = converse.env.utils;
|
||||||
|
|
||||||
|
|
||||||
@ -74,11 +74,14 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (result.image) {
|
if (result.image) {
|
||||||
const word_array_from_b64 = CryptoJS.enc.Base64.parse(result['image']);
|
const buffer = u.base64ToArrayBuffer(result['image']);
|
||||||
result['image_hash'] = CryptoJS.SHA1(word_array_from_b64).toString()
|
crypto.subtle.digest('SHA-1', buffer)
|
||||||
}
|
.then(ab => {
|
||||||
if (callback) {
|
result['image_hash'] = u.arrayBufferToHex(ab);
|
||||||
callback(result);
|
if (callback) callback(result);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (callback) callback(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user