From 384bfa0c567ac8d78248b72a1e2cc56a6f2053e8 Mon Sep 17 00:00:00 2001 From: "1362134550@qq.com" <1362134550@qq.com> Date: Fri, 26 Sep 2025 09:59:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entry/src/main/ets/pages/Index.ets | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/AppDataSecurity/entry/src/main/ets/pages/Index.ets b/AppDataSecurity/entry/src/main/ets/pages/Index.ets index 77abcf98..2baf5538 100644 --- a/AppDataSecurity/entry/src/main/ets/pages/Index.ets +++ b/AppDataSecurity/entry/src/main/ets/pages/Index.ets @@ -65,7 +65,7 @@ struct Index { } // [Start get_el2_path] - getEl2Path() { + getEl2Path(): void { let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.area = contextConstant.AreaMode.EL2; let filePath = context.filesDir + '/health_data.txt'; @@ -74,7 +74,7 @@ struct Index { // [End get_el2_path] // [Start get_el1_path] - getEl1Path() { + getEl1Path(): void { let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.area = contextConstant.AreaMode.EL1; let filePath = context.filesDir + '/health_data.txt'; @@ -83,14 +83,14 @@ struct Index { // [End get_el1_path] } -let aesKeyAlias = 'test_aesKeyAlias'; +let aesKeyAlias: string = 'test_aesKeyAlias'; let handle: number; -let plainText = '123456'; -let IV = '001122334455'; +let plainText: string = '123456'; +let IV: string = '001122334455'; let cipherData: Uint8Array; // [Start write_file] -function writeFile(filePath: string, data: string) { +function writeFile(filePath: string, data: string): void { try { let file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); let writeLen = fileIo.writeSync(file.fd, data); @@ -125,18 +125,18 @@ function readFile(filePath: string): string { } // [End write_file] -function StringToUint8Array(str: string) { +function StringToUint8Array(str: string): Uint8Array { let textEncoder = util.TextEncoder.create('utf-8'); return textEncoder.encodeInto(str); } -function Uint8ArrayToString(fileData: Uint8Array) { +function Uint8ArrayToString(fileData: Uint8Array): string { let textDecoder = util.TextDecoder.create('utf-8'); return textDecoder.decodeToString(fileData); } // [Start get_aes_generate_properties] -function GetAesGenerateProperties() { +function GetAesGenerateProperties(): Array { let properties: Array = [{ tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES @@ -153,7 +153,7 @@ function GetAesGenerateProperties() { // [End get_aes_generate_properties] // [Start get_aes_encrypt_properties] -function GetAesEncryptProperties() { +function GetAesEncryptProperties(): Array { let properties: Array = [{ tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES @@ -178,7 +178,7 @@ function GetAesEncryptProperties() { // [End get_aes_encrypt_properties] // [Start get_aes_decrypt_properties] -function GetAesDecryptProperties() { +function GetAesDecryptProperties(): Array { let properties: Array = [{ tag: huks.HuksTag.HUKS_TAG_ALGORITHM, value: huks.HuksKeyAlg.HUKS_ALG_AES @@ -203,7 +203,7 @@ function GetAesDecryptProperties() { // [End get_aes_decrypt_properties] // [Start generate_aes_key] -async function GenerateAesKey() { +async function GenerateAesKey(): Promise { let genProperties = GetAesGenerateProperties(); let options: huks.HuksOptions = { properties: genProperties @@ -219,7 +219,7 @@ async function GenerateAesKey() { // [End generate_aes_key] // [Start encrypt_data] -async function EncryptData() { +async function EncryptData(): Promise { let encryptProperties = GetAesEncryptProperties(); let options: huks.HuksOptions = { properties: encryptProperties, @@ -243,7 +243,7 @@ async function EncryptData() { }) } -async function DecryptData() { +async function DecryptData(): Promise { let decryptOptions = GetAesDecryptProperties() let options: huks.HuksOptions = { properties: decryptOptions, @@ -267,7 +267,7 @@ async function DecryptData() { } // [End encrypt_data] -async function DeleteKey() { +async function DeleteKey(): Promise { let emptyOptions: huks.HuksOptions = { properties: [] }; -- Gitee