16e7c69efSopenharmony_ci# Crypto Framework 26e7c69efSopenharmony_ci 36e7c69efSopenharmony_ci### Introduction 46e7c69efSopenharmony_ci 56e7c69efSopenharmony_ciThis sample shows how [@ohos.security.cryptoFramework](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md) works to implement the function of encrypting, decrypting, signing and verifying text file. The implementation scenario is as follows: 66e7c69efSopenharmony_ci 76e7c69efSopenharmony_ci1. The software needs to encrypt and store the local text file, and it needs to call Crypto Framework to select the key text file and encrypt the local text file, among which the key text file can be generated by Crypto Framework. 86e7c69efSopenharmony_ci 96e7c69efSopenharmony_ci2. The software needs to decrypt and store the local text file, and needs to call Crypto Framework to select the key text file and decrypt the local text file, where the key text file can be generated by Crypto Framework. 106e7c69efSopenharmony_ci 116e7c69efSopenharmony_ci3. The software needs to sign the stored local text file, call the encryption and Crypto Framework to select the key text file, and sign the integrity of the local text file, among which the key text file can be generated by Crypto Framework. 126e7c69efSopenharmony_ci 136e7c69efSopenharmony_ci4. The software needs to verify the signature integrity of the stored local text file, and needs to call Crypto Framework to select the key text file and the signature file, and verify and sign the file, among which the key text file can be generated by Crypto Framework. 146e7c69efSopenharmony_ci 156e7c69efSopenharmony_ci### Usage 166e7c69efSopenharmony_ci 176e7c69efSopenharmony_ci1. Click **Encrypted** in the tab bar of the main page, click **Open File** in the encrypt interface, select the text file through the file chooser, and automatically return to the encrypt interface after selection. 186e7c69efSopenharmony_ci Its contents are displayed in the **File Content** text box, 196e7c69efSopenharmony_ci Click **Select Key** to select the key file, if there is no key file, you can generate and save the key file through the file chooser by clicking **Generate AES Key Randomly** on the encryption interface. 206e7c69efSopenharmony_ci After selecting the text file and key file, click the **Encrypt** button to complete the encryption and save the ciphertext file through the file chooser.s 216e7c69efSopenharmony_ci The encrypted message content is displayed in the **Encrypted Content** text box below. 226e7c69efSopenharmony_ci 236e7c69efSopenharmony_ci2. Click **Decrypt** in the tab bar of the main page, click **Open File** on the decrypt interface, select the text file through the file chooser, and automatically return to the decrypt interface after selection. 246e7c69efSopenharmony_ci Its contents are displayed in the **File Content** text box, 256e7c69efSopenharmony_ci Click **Select Key** to select the same key file as Encryption. 266e7c69efSopenharmony_ci After selecting the text file and key file, click the **Decrypt** button to complete the decryption and save the plaintext file through the file chooser. 276e7c69efSopenharmony_ci The decrypted message content is displayed in the **Decrypted Content** text box below. 286e7c69efSopenharmony_ci 296e7c69efSopenharmony_ci3. Click **Signature** in the tab bar of the main page, click **Open File** on the sign interface, select the text file through the file chooser, and automatically return to the sign interface after selection. 306e7c69efSopenharmony_ci Its contents are displayed in the **File Content** text box, 316e7c69efSopenharmony_ci Click **Select Key** to select the key file, if there is no key file, you can generate and save the key file through the file selector by clicking **Generate RSA Key Randomly** on the signature interface, note that RSA key generation takes a long time. 326e7c69efSopenharmony_ci After selecting the text file and key file, click the **Sign** button to complete the integrity signature and save the signature file through the file chooser. 336e7c69efSopenharmony_ci 346e7c69efSopenharmony_ci4. Click the **Verify** tab bar of the main page, click **Open File** on the verify interface, select the text file through the file chooser, and automatically return to the verify interface after selection. 356e7c69efSopenharmony_ci Its contents are displayed in the **File Content** text box, 366e7c69efSopenharmony_ci Click **Select Key** to select a key file that matches the signature. Click **Select Signature File** to select the signature file saved when signing through the file chooser, 376e7c69efSopenharmony_ci After selecting the text file, key file, and signature file, click the **Verify** button to complete the signature verification. 386e7c69efSopenharmony_ci 396e7c69efSopenharmony_ci### Dependency 406e7c69efSopenharmony_ci 416e7c69efSopenharmony_ci* filePicker[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-file-picker.md) 426e7c69efSopenharmony_ci* fileManager[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-file-fs.md) 436e7c69efSopenharmony_ci* UI Ability Context[@ohos.app.ability.common](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md) 446e7c69efSopenharmony_ci 456e7c69efSopenharmony_ci### Constraints 466e7c69efSopenharmony_ci 476e7c69efSopenharmony_ci1. This sample can only be run on standard-system devices. 486e7c69efSopenharmony_ci2. This sample has been adapted to the API version 9 SDK, version number 3.2.12.2. 496e7c69efSopenharmony_ci3. This sample requires DevEco Studio 3.1 Release(Build Version: 3.1.0.500) to compile and run. 506e7c69efSopenharmony_ci4. This sample uses filePicker to select file, the files saved with filePicker, such as new keys generated, can be updated in real time, but the files directly pushed to the folder, they requires reboot the device and refresh the display. 516e7c69efSopenharmony_ci5. This sample supports text file currently only English characters, and as a demonstration, the length of text that can be used successfully does not exceed 8,000 bytes. 526e7c69efSopenharmony_ci 53