# encryption-utils
**Repository Path**: njk20/encryption-utils
## Basic Information
- **Project Name**: encryption-utils
- **Description**: 加密算法工具类
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-06-28
- **Last Updated**: 2024-06-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 加密解密算法工具
## V1.0-SNAPSHOT
### 使用方法
```xml
com.warm9
encryption-utils
1.0-SNAPSHOT
```
### 简介发布日期2024-06-28
```
本工具类包含了AES、DES、HmacSHA、HmacMD5、MD5、RSA、SHA算法
```
1. **新增AES算法(AesHelper)**
所属包名:com.warm9.com.aes
| 方法名称 | 方法说明 | 参数说明 |
| :-------------------------------------------------: | :-----------------: | :--------------------------------------------------: |
| String generateKey(int keySize) | 生成密钥 | keySize-密钥长度,AES算法支持128、192和256位密钥
|
| String encrypt(String plainText, String secretKey) | AES加密(明文,密钥) | plainText-明文
secretKey-密钥
|
| String decrypt(String ciphertext, String secretKey) | 解密(密文,密钥) | ciphertext-密文
secretKey-密钥
|
2. **新增DES算法(DesHelper)**
所属包名:com.warm9.des
| 方法名称 | 方法说明 | 参数说明 |
| :-------------------------------------------------: | :------: | :----------------------------------------------: |
| String generateKey() | 生成密钥 | |
| String encrypt(String plainText, String secretKey) | 加密 | plainText-明文
secretKey-密钥,最短8位
|
| String decrypt(String ciphertext, String secretKey) | 解密 | ciphertext-密文
secretKey-密钥,最短8位
|
3. **新增HmacSHA算法(HmacShaHelper)**
所属包名:com.warm9.hmacsha
| 方法名称 | 方法说明 | 参数说明 |
| :---------------------------------------------------: | :-------------: | :----------------------------------: |
| String hmacSha1(String plainText, String secretKey) | HmacSHA1 加密 | plainText-明文
secretKey-密钥
|
| String hmacSha224(String plainText, String secretKey) | HmacSHA224 加密 | plainText-明文
secretKey-密钥
|
| String hmacSha256(String plainText, String secretKey) | HmacSHA256 加密 | plainText-明文
secretKey-密钥
|
| String hmacSha384(String plainText, String secretKey) | HmacSHA384 加密 | plainText-明文
secretKey-密钥
|
| String hmacSha512(String plainText, String secretKey) | HmacSHA512 加密 | plainText-明文
secretKey-密钥
|
4. **新增HmacMD5算法(HmacMd5Helper)**
所属包名:com.warm9.md5
| 方法名称 | 方法说明 | 参数说明 |
| :--------------------------------------------: | :----------: | :----------------------------------: |
| String hmacMd5(String plainText,String secret) | HmacMd5 加密 | plainText-明文
secretKey-密钥
|
5. **新增MD5算法(Md5Helper)**
所属包名:com.warm9.md5
| 方法名称 | 方法说明 | 参数说明 |
| :------------------------------: | :------: | :----------------: |
| String encrypt(String plainText) | MD5加密 | plainText-明文
|
6. **新增RSA算法(RsaHelper)**
所属包名:
| 方法名称 | 方法说明 | 参数说明 |
| :----------------------------------------------------------: | :----------------------: | :------------------------------------------: |
| RsaSecretKey generateKey(int keySize) | 生成RSA密钥对 | keySize-密钥长度,通常为1024、2048、4096等 |
| boolean validateKeyPair(String publicKeyStr, String privateKeyStr) | 对生成的密钥对进行核验 | publicKeyStr-公钥字符串
privateKeyStr
|
| String encrypt(String plainText, String publicKeyStr) | 使用RSA公钥加密数据 | plainText-明文
publicKeyStr-RSA公钥
|
| String decrypt(String ciphertext,String privateKeyStr) | 使用RSA私钥解密数据 | ciphertext-密文
privateKeyStr-RSA私钥
|
| String removePublic(String publicKey) | 移除公钥前缀和后缀 | publicKey-公钥字符串
|
| String removePrivate(String privateKey) | 移除私钥前缀和后缀 | privateKey-私钥字符串
|
| String addPublic(String publicKey) | 添加公钥前缀、后缀、换行 | publicKey-公钥字符串
|
| String addPrivate(String privateKey) | 添加私钥前缀、后缀、换行 | privateKey-私钥字符串
|
7. **新增SHA算法(ShaHelper)**
所属包名:com.warm9.sha
| 方法名称 | 方法说明 | 参数说明 |
| :-----------------------------: | :-----------------------------: | :-----------------: |
| String sha1(String plainText) | 使用SHA-1算法对字符串进行加密 | plainText-明文
|
| String sha224(String plainText) | 使用SHA-224算法对字符串进行加密 | plainText-明文
|
| String sha256(String plainText) | 使用SHA-256算法对字符串进行加密 | plainText-明文
|
| String sha384(String plainText) | 使用SHA-384算法对字符串进行加密 | plainText-明文
|
| String sha512(String plainText) | 使用SHA-512算法对字符串进行加密 | plainText-明文
|