1
0
mirror of https://github.com/kamyu1537/eamuse-card-wasm.git synced 2024-11-27 21:10:48 +01:00

🐛 crypto.getRandomValues 에서 에러나는 문제 해결

This commit is contained in:
Byeon seongun 2020-04-04 16:04:03 +09:00
parent c27f4c75a1
commit e4b92cfe0e

View File

@ -1,3 +1,9 @@
crypto.getRandomValues = (buf) => {
buf = Buffer.from(buf);
let bytes = crypto.randomBytes(buf.length);
buf.set(bytes);
return buf;
};
require('./wasm_exec'); require('./wasm_exec');
const go = new Go(); const go = new Go();
@ -8,17 +14,17 @@ const wasmInstance = new WebAssembly.Instance(wasmModule, go.importObject);
go.run(wasmInstance).then(); go.run(wasmInstance).then();
module.exports.encode = function (nfcId) { module.exports.encode = function (nfcId) {
return new Promise(resolve => { return new Promise((resolve) => {
KONAMI_CARD_ENCODE(nfcId, function (result) { KONAMI_CARD_ENCODE(nfcId, function (result) {
resolve(result) resolve(result);
}) });
}) });
}; };
module.exports.decode = function (cardId) { module.exports.decode = function (cardId) {
return new Promise(resolve => { return new Promise((resolve) => {
KONAMI_CARD_DECODE(cardId, function (result) { KONAMI_CARD_DECODE(cardId, function (result) {
resolve(result) resolve(result);
}) });
}) });
}; };