[![Circle
CI](https://circleci.com/gh/rockaport/alice.svg?style=shield)](https://circleci.com/gh/rockaport/alice)
[![Build Status](https://travis-ci.org/rockaport/alice.svg?branch=master)](https://travis-ci.org/rockaport/alice)
[![Release](https://jitpack.io/v/rockaport/alice.svg)](https://jitpack.io/#rockaport/alice)
[![codecov](https://codecov.io/gh/rockaport/alice/branch/master/graph/badge.svg)](https://codecov.io/gh/rockaport/alice)
# alice
Alice is a Java AES/DES encryption library for working with byte arrays, files, and streams. Various key lengths, block modes, padding schemes, key deriviation functions, and Message Authentication Codes (MAC) are available. See the [javadoc](https://rockaport.github.io/alice) for more information.
Alice provides an easy wrapper around the javax.crypto cipher suite for symmetric key encryption. if a MAC algorithm is selected, additional [Authenticated Encryption](https://en.wikipedia.org/wiki/Authenticated_encryption) is performed using an [encrypt-then-mac](https://en.wikipedia.org/wiki/Authenticated_encryption#Encrypt-then-MAC_.28EtM.29) scheme.
![Data Structure](https://cloud.githubusercontent.com/assets/5369654/23003382/82fa26d0-f3be-11e6-8128-ce2ef6f71957.png)
Algorithms
- AES
- DES
- DESede (3DES)
Modes
- CBC (AES & DES & DESede)
- CTR (AES & DES & DESede)
- GCM (AES)
Padding
- NoPadding
- PKCS5Padding
Key Lengths (in bits)
- 64 (DES)
- 128 (AES)
- 192 (AES & DESede)
- 256 (AES)
Password Based Key Derivation Functions (PBKDF)
- None (use password as is, zero padded if necessary)
- SHA-{1, 224, 256, 384, 512} (hashes the password before use)
- PBKDF2WithHmacSHA{1, 256, 384, 512} (derives the key using a password-based key-derivation algorithm)
MAC Algorithm (Authenticated Encryption)
- None
- HmacSHA{1, 256, 384, 512}
IV Length
- 8 (DES & DESede)
- 16 (AES-CBC/CTR mode)
- Varies (GCM)
GCM Tag Length (in bits)
- 96
- 104
- 112
- 120
- 128
Iterations (used when the PBKDF = PBKDF2WithHmacSHA{Length})
- Varies
# Download
The easist way is to use [jitpack](https://jitpack.io/#rockaport/alice)
# Usage
## Initialization
```java
// Initialize an Alice instance with defaults:
// Cipher = AES/256/CTR/NoPadding
// Key Derivation = PBKDF2WithHmacSHA512/Iterations(10000)
// MAC = HmacSHA512
Alice alice = new Alice(new AliceContextBuilder().build());
```
### AES-CBC or CTR context initialization
```java
AliceContext aliceContext = new AliceContextBuilder()
.setAlgorithm(AliceContext.Algorithm.AES)
.setMode(AliceContext.Mode.CBC) // or AliceContext.Mode.CTR
.setIvLength(16)
.build()
```
### AES-GCM Context Initialization
```java
AliceContext aliceContext = new AliceContextBuilder()
.setAlgorithm(AliceContext.Algorithm.AES)
.setMode(AliceContext.Mode.GCM)
.setIvLength(ivLength) // e.g. 12
.setGcmTagLength(AliceContext.GcmTagLength.BITS_128)
.build()
```
### DES-CBC or CTR Context Initialization
```java
AliceContext aliceContext = new AliceContextBuilder()
.setAlgorithm(AliceContext.Algorithm.DES)
.setMode(AliceContext.Mode.CBC) // or AliceContext.Mode.CTR
.setIvLength(8)
.build()
```
### 3DES-CBC or CTR Context Initialization
```java
AliceContext aliceContext = new AliceContextBuilder()
.setAlgorithm(AliceContext.Algorithm.DESede)
.setMode(AliceContext.Mode.CBC) // or AliceContext.Mode.CTR
.setIvLength(8)
.build()
```
## Encryption
After you've created an Alice instance with the desired context you can encrypt/decrypt byte arrays and files as shown. See the unit tests for more detailed usage and options.
### Working with byte arrays
```java
byte[] encryptedBytes = alice.encrypt(input, password);
byte[] decryptedBytes = alice.decrypt(encryptedBytes, password);
```
### Working with files
```java
alice.encrypt(inputFile, encryptedFile, password);
alice.decrypt(encryptedFile, decryptedFile, password);
```
### Working with streams
Note: Streaming encryption does not support authenticated encryption. You must set the mac algorithm to AliceContext.MacAlgorithm.NONE
```java
alice.encrypt(inputStream, encryptedStream, password);
alice.decrypt(encryptedStream, decryptedStream, password);
```
没有合适的资源?快使用搜索试试~ 我知道了~
JavaAES加密库.zip
共43个文件
html:21个
java:4个
gradle:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 134 浏览量
2023-03-26
23:58:37
上传
评论
收藏 130KB ZIP 举报
温馨提示
JavaAES加密库.zip
资源推荐
资源详情
资源评论
收起资源包目录
JavaAES加密库.zip (43个子文件)
alice-master
gradle
wrapper
gradle-wrapper.jar 52KB
gradle-wrapper.properties 230B
.travis.yml 154B
.gitattributes 31B
circle.yml 197B
LICENSE 11KB
gradlew.bat 2KB
build.gradle 147B
docs
deprecated-list.html 4KB
allclasses-noframe.html 2KB
package-list 20B
constant-values.html 4KB
stylesheet.css 13KB
index.html 3KB
help-doc.html 10KB
overview-tree.html 8KB
index-all.html 34KB
allclasses-frame.html 2KB
com
rockaport
alice
package-summary.html 11KB
package-tree.html 8KB
AliceContext.html 34KB
AliceContextBuilder.html 37KB
AliceContext.KeyLength.html 23KB
AliceContext.GcmTagLength.html 24KB
AliceContext.Algorithm.html 24KB
AliceContext.MacAlgorithm.html 24KB
AliceContext.Pbkdf.html 32KB
package-frame.html 2KB
AliceContext.Padding.html 22KB
AliceContext.Mode.html 23KB
Alice.html 29KB
script.js 811B
settings.gradle 16B
gradlew 5KB
alice
src
test
groovy
com.rockaport.alice
AliceTest.groovy 71KB
AliceContextTest.groovy 3KB
main
java
com
rockaport
alice
AliceContextBuilder.java 4KB
AliceContext.java 9KB
Alice.java 24KB
package-info.java 242B
build.gradle 1KB
.gitignore 397B
README.md 4KB
共 43 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功