refactor decryptAttribute
This commit is contained in:
parent
b6a2a5fc3b
commit
ec9fe0f62c
@ -1433,21 +1433,21 @@ export default class Services {
|
|||||||
// Decrypt the data
|
// Decrypt the data
|
||||||
const buf = await blob.arrayBuffer();
|
const buf = await blob.arrayBuffer();
|
||||||
const cipher = new Uint8Array(buf);
|
const cipher = new Uint8Array(buf);
|
||||||
const keyBlob = this.hexToBlob(key);
|
|
||||||
const keyBuf = await keyBlob.arrayBuffer();
|
const keyUIntArray = this.hexToUInt8Array(key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const clear = this.sdkClient.decrypt_data(new Uint8Array(keyBuf), cipher);
|
const clear = this.sdkClient.decrypt_data(keyUIntArray, cipher);
|
||||||
if (clear) {
|
if (clear) {
|
||||||
// deserialize the result to get the actual data
|
// deserialize the result to get the actual data
|
||||||
const decoded = this.sdkClient.decode_value(clear);
|
const decoded = this.sdkClient.decode_value(clear);
|
||||||
console.log('Decoded value:', JSON.stringify(decoded));
|
// console.log('Decoded value:', JSON.stringify(decoded));
|
||||||
return decoded;
|
return decoded;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('decrypt_data returned null');
|
throw new Error('decrypt_data returned null');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to decrypt data:', e.toString());
|
console.error(`Failed to decrypt data: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user