1e41f4b71Sopenharmony_ci# Encryption and Decryption with an RSA Asymmetric Key Pair (PKCS1)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciFor details about the algorithm specifications, see [RSA](crypto-asym-encrypt-decrypt-spec.md#rsa).
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci**Encryption**
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci1. Use [cryptoFramework.createAsyKeyGenerator](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#cryptoframeworkcreateasykeygenerator) and [AsyKeyGenerator.generateKeyPair](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#generatekeypair-1) to generate a 1024-bit RSA asymmetric key pair (**KeyPair**) with two primes. The **KeyPair** object includes a public key (**PubKey**) and a private key (**PriKey**).
11e41f4b71Sopenharmony_ci   
12e41f4b71Sopenharmony_ci   In addition to the example in this topic, [RSA](crypto-asym-key-generation-conversion-spec.md#rsa) and [Randomly Generating an Asymmetric Key Pair](crypto-generate-asym-key-pair-randomly.md) may help you better understand how to generate an RSA asymmetric key pair. Note that the input parameters in the reference documents may be different from those in the example below.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci2. Use [cryptoFramework.createCipher](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#cryptoframeworkcreatecipher) with the string parameter **'RSA1024|PKCS1'** to create a **Cipher** instance for encryption. The key type is **RSA1024**, and the padding mode is **PKCS1**.
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci3. Use [Cipher.init](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#init-1) to initialize the **Cipher** instance. In **Cipher.init**, set **opMode** to **CryptoMode.ENCRYPT_MODE** (encryption) and **key** to **KeyPair.PubKey** (the key used for encryption).
17e41f4b71Sopenharmony_ci   
18e41f4b71Sopenharmony_ci   No encryption parameter is required for asymmetric key pairs. Therefore, pass in **null** in **params**.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci4. Use [Cipher.doFinal](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#dofinal-1) to pass in the plaintext and encrypt it.
21e41f4b71Sopenharmony_ci   
22e41f4b71Sopenharmony_ci   - The output of **Cipher.doFinal** may be **null**. To avoid exceptions, always check whether the result is **null** before accessing specific data.
23e41f4b71Sopenharmony_ci   - If a large amount of data is to be encrypted, you can call **Cipher.doFinal** multiple times to pass in the data by segment.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Decryption**
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci1. If RSA is used, the **Cipher** instance cannot be initialized repeatedly. Use [cryptoFramework.createCipher](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#cryptoframeworkcreatecipher) to create a new **Cipher** instance.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci2. Use [Cipher.init](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#init-1) to initialize the **Cipher** instance. In **Cipher.init**, set **opMode** to **CryptoMode.DECRYPT_MODE** (decryption) and **key** to **KeyPair.PriKey** (the key used for decryption). When PKCS1 mode is used, pass in **null** in **params**.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci3. Use [Cipher.doFinal](../../reference/apis-crypto-architecture-kit/js-apis-cryptoFramework.md#dofinal-1) to pass in the ciphertext and decrypt it.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci- Example (using asynchronous APIs):
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci  ```ts
39e41f4b71Sopenharmony_ci  import { cryptoFramework } from '@kit.CryptoArchitectureKit';
40e41f4b71Sopenharmony_ci  import { buffer } from '@kit.ArkTS';
41e41f4b71Sopenharmony_ci  // Encrypt the message.
42e41f4b71Sopenharmony_ci  async function encryptMessagePromise(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) {
43e41f4b71Sopenharmony_ci    let cipher = cryptoFramework.createCipher('RSA1024|PKCS1');
44e41f4b71Sopenharmony_ci    await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null);
45e41f4b71Sopenharmony_ci    let encryptData = await cipher.doFinal(plainText);
46e41f4b71Sopenharmony_ci    return encryptData;
47e41f4b71Sopenharmony_ci  }
48e41f4b71Sopenharmony_ci  // Decrypt the message.
49e41f4b71Sopenharmony_ci  async function decryptMessagePromise(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) {
50e41f4b71Sopenharmony_ci    let decoder = cryptoFramework.createCipher('RSA1024|PKCS1');
51e41f4b71Sopenharmony_ci    await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null);
52e41f4b71Sopenharmony_ci    let decryptData = await decoder.doFinal(cipherText);
53e41f4b71Sopenharmony_ci    return decryptData;
54e41f4b71Sopenharmony_ci  }
55e41f4b71Sopenharmony_ci  // Generates an RSA key pair.
56e41f4b71Sopenharmony_ci  async function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) {
57e41f4b71Sopenharmony_ci    let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData };
58e41f4b71Sopenharmony_ci    let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData };
59e41f4b71Sopenharmony_ci    let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024');
60e41f4b71Sopenharmony_ci    let keyPair = await rsaGenerator.convertKey(pubKeyBlob, priKeyBlob);
61e41f4b71Sopenharmony_ci    console.info('convertKey success');
62e41f4b71Sopenharmony_ci    return keyPair;
63e41f4b71Sopenharmony_ci  }
64e41f4b71Sopenharmony_ci  async function main() {
65e41f4b71Sopenharmony_ci    let pkData = new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1]);
66e41f4b71Sopenharmony_ci    let skData = new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1, 2, 129, 128, 70, 75, 184, 139, 53, 1, 94, 17, 240, 244, 218, 101, 193, 253, 215, 190, 164, 204, 197, 192, 200, 89, 107, 39, 171, 119, 65, 38, 204, 168, 105, 180, 234, 217, 16, 161, 185, 132, 175, 103, 25, 154, 153, 153, 36, 36, 26, 178, 150, 66, 45, 8, 185, 19, 90, 228, 210, 177, 30, 200, 177, 141, 78, 184, 248, 59, 113, 154, 145, 73, 160, 24, 73, 157, 86, 207, 186, 32, 95, 200, 106, 252, 107, 69, 170, 193, 216, 196, 181, 142, 74, 203, 15, 18, 89, 228, 152, 19, 239, 21, 233, 98, 121, 214, 57, 187, 111, 239, 223, 248, 199, 70, 223, 108, 108, 113, 234, 144, 155, 95, 246, 144, 244, 122, 39, 55, 127, 81, 2, 65, 0, 246, 96, 188, 0, 0, 104, 221, 105, 139, 144, 63, 175, 209, 87, 179, 162, 88, 192, 99, 82, 125, 53, 54, 48, 70, 245, 239, 37, 15, 242, 247, 84, 115, 187, 196, 95, 156, 40, 165, 60, 64, 102, 13, 229, 243, 2, 149, 0, 232, 226, 221, 192, 95, 11, 12, 208, 5, 181, 98, 62, 210, 190, 141, 235, 2, 65, 0, 204, 244, 34, 10, 105, 80, 76, 116, 163, 35, 231, 168, 187, 206, 189, 101, 215, 103, 80, 115, 86, 11, 34, 127, 203, 114, 84, 188, 121, 174, 169, 31, 142, 2, 182, 27, 140, 225, 157, 227, 71, 98, 15, 203, 187, 213, 5, 190, 20, 121, 8, 30, 193, 100, 232, 101, 141, 8, 124, 20, 29, 78, 6, 95, 2, 65, 0, 204, 43, 225, 224, 6, 118, 224, 117, 100, 200, 199, 94, 70, 23, 109, 175, 173, 232, 208, 230, 61, 8, 105, 189, 156, 48, 150, 91, 154, 89, 248, 136, 173, 215, 254, 166, 84, 220, 130, 1, 234, 68, 40, 100, 84, 251, 224, 202, 254, 51, 115, 28, 198, 38, 124, 25, 175, 129, 94, 199, 61, 17, 216, 189, 2, 64, 72, 230, 129, 129, 48, 138, 134, 87, 106, 123, 231, 247, 165, 173, 216, 194, 115, 198, 228, 223, 209, 120, 46, 114, 68, 92, 75, 117, 170, 214, 140, 131, 147, 208, 181, 19, 193, 157, 178, 186, 87, 246, 178, 101, 166, 79, 20, 54, 211, 51, 101, 199, 2, 197, 48, 192, 134, 84, 193, 69, 170, 82, 201, 131, 2, 65, 0, 213, 165, 55, 166, 131, 210, 195, 56, 250, 147, 195, 61, 205, 208, 189, 185, 40, 52, 50, 119, 137, 23, 246, 46, 220, 108, 52, 23, 152, 154, 94, 32, 144, 195, 184, 249, 21, 168, 12, 57, 222, 18, 60, 117, 81, 157, 72, 30, 155, 190, 165, 242, 228, 139, 240, 184, 145, 170, 103, 210, 160, 161, 135, 13]);
67e41f4b71Sopenharmony_ci    let keyPair = await genKeyPairByData(pkData, skData);
68e41f4b71Sopenharmony_ci    let pubKey = keyPair.pubKey;
69e41f4b71Sopenharmony_ci    let priKey = keyPair.priKey;
70e41f4b71Sopenharmony_ci    let message = 'This is a test';
71e41f4b71Sopenharmony_ci    // Decode the string into a Uint8Array in UTF-8 format.
72e41f4b71Sopenharmony_ci    let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) };
73e41f4b71Sopenharmony_ci    let encryptText = await encryptMessagePromise(pubKey, plainText);
74e41f4b71Sopenharmony_ci    let decryptText = await decryptMessagePromise(priKey, encryptText);
75e41f4b71Sopenharmony_ci    if (plainText.data.toString() === decryptText.data.toString()) {
76e41f4b71Sopenharmony_ci      console.info('decrypt ok');
77e41f4b71Sopenharmony_ci      // Encode the Uint8Array into a string in UTF-8 format.
78e41f4b71Sopenharmony_ci      let messageDecrypted = buffer.from(decryptText.data).toString('utf-8');
79e41f4b71Sopenharmony_ci      console.info('decrypted result string:' + messageDecrypted);
80e41f4b71Sopenharmony_ci    } else {
81e41f4b71Sopenharmony_ci      console.error('decrypt failed');
82e41f4b71Sopenharmony_ci    }
83e41f4b71Sopenharmony_ci  }
84e41f4b71Sopenharmony_ci  ```
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci- Example (using synchronous APIs):
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci  ```ts
89e41f4b71Sopenharmony_ci  import { cryptoFramework } from '@kit.CryptoArchitectureKit';
90e41f4b71Sopenharmony_ci  import { buffer } from '@kit.ArkTS';
91e41f4b71Sopenharmony_ci  // Encrypt the message.
92e41f4b71Sopenharmony_ci  function encryptMessage(publicKey: cryptoFramework.PubKey, plainText: cryptoFramework.DataBlob) {
93e41f4b71Sopenharmony_ci    let cipher = cryptoFramework.createCipher('RSA1024|PKCS1');
94e41f4b71Sopenharmony_ci    cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, publicKey, null);
95e41f4b71Sopenharmony_ci    let encryptData = cipher.doFinalSync(plainText);
96e41f4b71Sopenharmony_ci    return encryptData;
97e41f4b71Sopenharmony_ci  }
98e41f4b71Sopenharmony_ci  // Decrypt the message.
99e41f4b71Sopenharmony_ci  function decryptMessage(privateKey: cryptoFramework.PriKey, cipherText: cryptoFramework.DataBlob) {
100e41f4b71Sopenharmony_ci    let decoder = cryptoFramework.createCipher('RSA1024|PKCS1');
101e41f4b71Sopenharmony_ci    decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, privateKey, null);
102e41f4b71Sopenharmony_ci    let decryptData = decoder.doFinalSync(cipherText);
103e41f4b71Sopenharmony_ci    return decryptData;
104e41f4b71Sopenharmony_ci  }
105e41f4b71Sopenharmony_ci  // Generates an RSA key pair.
106e41f4b71Sopenharmony_ci  async function genKeyPairByData(pubKeyData: Uint8Array, priKeyData: Uint8Array) {
107e41f4b71Sopenharmony_ci    let pubKeyBlob: cryptoFramework.DataBlob = { data: pubKeyData };
108e41f4b71Sopenharmony_ci    let priKeyBlob: cryptoFramework.DataBlob = { data: priKeyData };
109e41f4b71Sopenharmony_ci    let rsaGenerator = cryptoFramework.createAsyKeyGenerator('RSA1024');
110e41f4b71Sopenharmony_ci    let keyPair = await rsaGenerator.convertKey(pubKeyBlob, priKeyBlob);
111e41f4b71Sopenharmony_ci    console.info('convertKey success');
112e41f4b71Sopenharmony_ci    return keyPair;
113e41f4b71Sopenharmony_ci  }
114e41f4b71Sopenharmony_ci  async function main() {
115e41f4b71Sopenharmony_ci    let pkData = new Uint8Array([48, 129, 159, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 129, 141, 0, 48, 129, 137, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1]);
116e41f4b71Sopenharmony_ci    let skData = new Uint8Array([48, 130, 2, 119, 2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130, 2, 97, 48, 130, 2, 93, 2, 1, 0, 2, 129, 129, 0, 197, 64, 10, 198, 14, 110, 65, 92, 206, 35, 28, 123, 153, 24, 134, 255, 145, 74, 42, 173, 40, 215, 146, 58, 143, 46, 10, 195, 154, 160, 69, 196, 220, 152, 179, 44, 111, 200, 84, 78, 215, 73, 210, 181, 12, 29, 70, 68, 36, 135, 153, 89, 230, 202, 130, 212, 111, 243, 234, 92, 131, 62, 145, 50, 73, 48, 104, 245, 46, 70, 45, 157, 147, 143, 140, 162, 156, 216, 220, 49, 121, 142, 194, 33, 223, 201, 0, 16, 163, 210, 240, 118, 92, 147, 121, 220, 17, 114, 24, 52, 125, 135, 176, 88, 21, 83, 86, 17, 156, 88, 250, 48, 79, 86, 128, 248, 105, 208, 133, 140, 13, 153, 164, 191, 136, 164, 44, 53, 2, 3, 1, 0, 1, 2, 129, 128, 70, 75, 184, 139, 53, 1, 94, 17, 240, 244, 218, 101, 193, 253, 215, 190, 164, 204, 197, 192, 200, 89, 107, 39, 171, 119, 65, 38, 204, 168, 105, 180, 234, 217, 16, 161, 185, 132, 175, 103, 25, 154, 153, 153, 36, 36, 26, 178, 150, 66, 45, 8, 185, 19, 90, 228, 210, 177, 30, 200, 177, 141, 78, 184, 248, 59, 113, 154, 145, 73, 160, 24, 73, 157, 86, 207, 186, 32, 95, 200, 106, 252, 107, 69, 170, 193, 216, 196, 181, 142, 74, 203, 15, 18, 89, 228, 152, 19, 239, 21, 233, 98, 121, 214, 57, 187, 111, 239, 223, 248, 199, 70, 223, 108, 108, 113, 234, 144, 155, 95, 246, 144, 244, 122, 39, 55, 127, 81, 2, 65, 0, 246, 96, 188, 0, 0, 104, 221, 105, 139, 144, 63, 175, 209, 87, 179, 162, 88, 192, 99, 82, 125, 53, 54, 48, 70, 245, 239, 37, 15, 242, 247, 84, 115, 187, 196, 95, 156, 40, 165, 60, 64, 102, 13, 229, 243, 2, 149, 0, 232, 226, 221, 192, 95, 11, 12, 208, 5, 181, 98, 62, 210, 190, 141, 235, 2, 65, 0, 204, 244, 34, 10, 105, 80, 76, 116, 163, 35, 231, 168, 187, 206, 189, 101, 215, 103, 80, 115, 86, 11, 34, 127, 203, 114, 84, 188, 121, 174, 169, 31, 142, 2, 182, 27, 140, 225, 157, 227, 71, 98, 15, 203, 187, 213, 5, 190, 20, 121, 8, 30, 193, 100, 232, 101, 141, 8, 124, 20, 29, 78, 6, 95, 2, 65, 0, 204, 43, 225, 224, 6, 118, 224, 117, 100, 200, 199, 94, 70, 23, 109, 175, 173, 232, 208, 230, 61, 8, 105, 189, 156, 48, 150, 91, 154, 89, 248, 136, 173, 215, 254, 166, 84, 220, 130, 1, 234, 68, 40, 100, 84, 251, 224, 202, 254, 51, 115, 28, 198, 38, 124, 25, 175, 129, 94, 199, 61, 17, 216, 189, 2, 64, 72, 230, 129, 129, 48, 138, 134, 87, 106, 123, 231, 247, 165, 173, 216, 194, 115, 198, 228, 223, 209, 120, 46, 114, 68, 92, 75, 117, 170, 214, 140, 131, 147, 208, 181, 19, 193, 157, 178, 186, 87, 246, 178, 101, 166, 79, 20, 54, 211, 51, 101, 199, 2, 197, 48, 192, 134, 84, 193, 69, 170, 82, 201, 131, 2, 65, 0, 213, 165, 55, 166, 131, 210, 195, 56, 250, 147, 195, 61, 205, 208, 189, 185, 40, 52, 50, 119, 137, 23, 246, 46, 220, 108, 52, 23, 152, 154, 94, 32, 144, 195, 184, 249, 21, 168, 12, 57, 222, 18, 60, 117, 81, 157, 72, 30, 155, 190, 165, 242, 228, 139, 240, 184, 145, 170, 103, 210, 160, 161, 135, 13]);
117e41f4b71Sopenharmony_ci    let keyPair = await genKeyPairByData(pkData, skData);
118e41f4b71Sopenharmony_ci    let pubKey = keyPair.pubKey;
119e41f4b71Sopenharmony_ci    let priKey = keyPair.priKey;
120e41f4b71Sopenharmony_ci    let message = 'This is a test';
121e41f4b71Sopenharmony_ci    // Decode the string into a Uint8Array in UTF-8 format.
122e41f4b71Sopenharmony_ci    let plainText: cryptoFramework.DataBlob = { data: new Uint8Array(buffer.from(message, 'utf-8').buffer) };
123e41f4b71Sopenharmony_ci    let encryptText = encryptMessage(pubKey, plainText);
124e41f4b71Sopenharmony_ci    let decryptText = decryptMessage(priKey, encryptText);
125e41f4b71Sopenharmony_ci    if (plainText.data.toString() === decryptText.data.toString()) {
126e41f4b71Sopenharmony_ci      console.info('decrypt ok');
127e41f4b71Sopenharmony_ci      // Encode the Uint8Array into a string in UTF-8 format.
128e41f4b71Sopenharmony_ci      let messageDecrypted = buffer.from(decryptText.data).toString('utf-8');
129e41f4b71Sopenharmony_ci      console.info('decrypted result string:' + messageDecrypted);
130e41f4b71Sopenharmony_ci    } else {
131e41f4b71Sopenharmony_ci      console.error('decrypt failed');
132e41f4b71Sopenharmony_ci    }
133e41f4b71Sopenharmony_ci  }
134e41f4b71Sopenharmony_ci  ```
135