harmony 鸿蒙Basic Security Capability Development
Basic Security Capability Development
What is the maximum number of bytes that can be encrypted at a time in AES GCM mode in HUKS?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
Solution
In HUKS, a maximum of 64 bytes can be encrypted at a time in AES GCM mode.
Example
/* Encrypt the key. */
await huks.init(srcKeyAlias, encryptOptions).then((data) => {
console.info(`test init data: ${JSON.stringify(data)}`);
handle = data.handle;
}).catch((err) => {
console.info('test init err information: ' + JSON.stringify(err));
});
encryptOptions.inData = aesCipherStringToUint8Array(cipherInData.slice (0,64)); // Take 64 bytes.
await huks.update(handle, encryptOptions).then(async (data) => {
console.info(`test update data ${JSON.stringify(data)}`);
encryptUpdateResult = Array.from(data.outData);
}).catch((err) => {
console.info('test update err information: ' + err);
});
encryptOptions.inData = aesCipherStringToUint8Array(cipherInData.slice (64,80)); // Remaining data
What if garbled characters are returned by digest() of Md in Crypto framework?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
Symptom
In the CryptoFramework, garbled characters are returned by digest() of Md.
Solution
The DataBlob returned by digest() is of the Uint8Array type and needs to be converted into a hexadecimal string before being printed. You can use the online MD5 encryption tool to verify the result.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Using NDK in a CMake Project
harmony 鸿蒙Application Access Control Development
harmony 鸿蒙Application Model Development
harmony 鸿蒙ArkUI Animation/Interaction Event Development (ArkTS)
harmony 鸿蒙ArkUI Component Development (ArkTS)
harmony 鸿蒙ArkUI Development (JS)
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦