| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 54 | 49 | ||
| entry/ | 06-May-2025 | - | 1,349 | 1,164 | ||
| hvigor/ | 06-May-2025 | - | 24 | 22 | ||
| screenshots/device/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 142 | 11 | 11 | |
| README.md | D | 06-May-2025 | 1.5 KiB | 38 | 19 | |
| README_zh.md | D | 06-May-2025 | 3.9 KiB | 84 | 58 | |
| build-profile.json5 | D | 06-May-2025 | 1 KiB | 43 | 41 | |
| hvigorfile.ts | D | 06-May-2025 | 158 | 2 | 1 | |
| hvigorw | D | 06-May-2025 | 2.1 KiB | 64 | 28 | |
| hvigorw.bat | D | 06-May-2025 | 2 KiB | 73 | 56 | |
| oh-package.json5 | D | 06-May-2025 | 812 | 27 | 25 | |
| ohosTest.md | D | 06-May-2025 | 1.2 KiB |
README.md
1# Cipher 2 3### Introduction 4 5This sample shows how to use cipher algorithms, including Rivest-Shamir-Adleman (RSA) and Advanced Encryption Standard (AES). The display effect is as follows: 6 7   8 9### Concepts 10 11RSA: A public-key cryptosystem that works on two different keys: a public encryption key and a private decryption key. 12 13AES: A block encryption standard established by the U.S. National Institute of Standards and technology (NIST). It is also called Rijndael. 14 15### Required Permissions 16 17N/A. 18 19### Usage 20 211. On the home screen, touch the **Encrypt** button. On the **Encrypt** screen, select an encryption algorithm from the **Encryption Algorithm** drop-down list box, enter the content to be encrypted in the text box, and touch the **Encrypt** button. 22 23 The encrypted content is displayed in the text box below. 24 252. Touch the **Reset** button to clear the content in the text box. 26 273. Touch the **Decrypt** button on the home screen. On the **Decrypt** screen, select a decryption algorithm from the **Decryption Algorithm** drop-down list box, enter the content to be decrypted in the text box, and touch the **Decrypt** button. 28 29 The decrypted content is displayed in the text box below. 30 314. Touch the **Reset** button to clear the content in the text box. 32 33### Constraints 34 35- This sample can only be run on standard-system devices. 36 37- This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) to compile and run. 38
README_zh.md
1# 加解密 2 3### 介绍 4 5本示例使用[cipher](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-crypto-architecture-kit/js-apis-system-cipher.md)相关接口实现了字符串加解密算法,包括RSA加密算法与AES加密算法。 6 7RSA加密算法:RSA公开密钥密码体制是一种使用不同的加密密钥与解密密钥,由已知加密密钥推导出解密密钥在计算上是不可行的密码体制。 8 9AES加密算法:AES密码学中的高级加密标准,又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准。 10 11### 效果预览 12 13|主页|加密页面|解密页面| 14|--------------------------------|--------------------------------|--------------------------------| 15||  || 16 17使用说明 18 191.点击主页面的**加密**按钮,在加密界面中点击**Encryption Algorithm**下拉选择加密算法,在输入框中输入待加密的内容,点击**加密** 20按钮,下方文本框中显示加密后内容。 21 222.点击**重置**按钮,清除文本框中内容。 23 243.点击主页面的**解密**按钮,在解密界面中点击**Decrypt Algorithm**下拉选择解密算法,在输入框中输入待解密的内容,点击**解密** 25按钮,下方文本框中显示解密后内容。 26 274.点击**重置**按钮,清除文本框中内容。 28 29### 工程目录 30``` 31entry/src/main/ets/ 32|---common 33| |---Decrypt.ets // 解密页面 34| |---Encryption.ets // 加密页面 35|---entryAbility 36| |---EntryAbility.ts 37|---model 38| |---CipherModel.ts // 加密与解密方法 39| |---Logger.ts // 日志工具 40|---pages 41| |---Index.ets // 首页 42| |---Second.ets // 加密与解密页面 43``` 44 45### 具体实现 46 47* 本示例分成加密与解密两个模块 48 * 加密模块 49 * 使用到rsaEncrypt(RSA算法加密)与aesEncrypt(AES算法加密)两种加密方法进行加密操作。 50 * 源码链接:[Encryption.ets](entry/src/main/ets/common/Encryption.ets),[CipherModel.ts](entry/src/main/ets/model/CipherModel.ts) 51 * 接口参考:[@system.cipher](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-crypto-architecture-kit/js-apis-system-cipher.md),[@ohos.prompt](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-arkui/js-apis-prompt.md),[@system.router](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-arkui/js-apis-system-router.md) 52 53 * 解密模块 54 * 使用到rsaDecrypt(RSA算法解密)与aesDecrypt(AES算法解密)两种解密方法进行解密操作。 55 * 源码链接:[Decrypt.ets](entry/src/main/ets/common/Decrypt.ets),[CipherModel.ts](entry/src/main/ets/model/CipherModel.ts) 56 * 接口参考:[@system.cipher](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-crypto-architecture-kit/js-apis-system-cipher.md),[@ohos.prompt](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-arkui/js-apis-prompt.md),[@system.router](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-arkui/js-apis-system-router.md) 57 58### 相关权限 59 60不涉及。 61 62### 依赖 63 64不涉及。 65 66### 约束与限制 67 681.本示例仅支持在标准系统上运行。 69 702.本示例已适配API version 9版本SDK,版本号:3.2.11.9。 71 723.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。 73 74### 下载 75 76如需单独下载本工程,执行如下命令: 77``` 78git init 79git config core.sparsecheckout true 80echo code/BasicFeature/Security/Cipher/ > .git/info/sparse-checkout 81git remote add origin https://gitee.com/openharmony/applications_app_samples.git 82git pull origin master 83 84```