Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtdowney/chloride
An easy to use wrapped around Java Crypto libraries
https://github.com/jtdowney/chloride
Last synced: about 1 month ago
JSON representation
An easy to use wrapped around Java Crypto libraries
- Host: GitHub
- URL: https://github.com/jtdowney/chloride
- Owner: jtdowney
- License: mit
- Created: 2015-03-11T02:00:06.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-03-16T19:09:21.000Z (almost 8 years ago)
- Last Synced: 2024-10-16T14:59:38.381Z (3 months ago)
- Language: Java
- Homepage: http://jtdowney.github.io/chloride
- Size: 111 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# chloride
[![Build Status](https://travis-ci.org/jtdowney/chloride.svg)](https://travis-ci.org/jtdowney/chloride)
Chloride provides a simple API over Java's crypto functionality. It uses [Bouncy Castle](https://www.bouncycastle.org/java.html) to provide support for modern algorithms. The API is loosely modeled after [NaCl](http://nacl.cr.yp.to/) and [libsodium](https://github.com/jedisct1/libsodium).
## Algorithms
Under the hood, `chloride` uses [NSA Suite B Cryptography](http://en.wikipedia.org/wiki/NSA_Suite_B_Cryptography). This means it uses AES-256-GCM to encrypt data and for asymmetric boxes it uses ECDH with curve P-256 for key agreement.
## Requirements
1. You need to [install Bouncy Castle as a JCE provider](http://www.bouncycastle.org/wiki/display/JA1/Provider+Installation).
2. You need the [Java Crypto Unlimited Strength Policy files](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html).## Usage
### Box (asymmetric encryption)
```java
KeyPair pair1 = KeyPair.generate();
KeyPair pair2 = KeyPair.generate();
Box box1 = new Box(pair1.getPrivateKey(), pair2.getPublicKey());
Box box2 = new Box(pair2.getPrivateKey(), pair1.getPublicKey());byte[] ciphertext = box1.encrypt("too many secrets".getBytes("UTF-8"));
byte[] plaintext = box2.decrypt(ciphertext);
```### Secret Box (symmetric encryption)
```java
SecretKey key = SecretKey.generate();
SecretBox box = new SecretBox(key);
byte[] ciphertext = box.encrypt("too many secrets".getBytes("UTF-8"));
byte[] plaintext = box.decrypt(ciphertext);
```## Security
Chloride uses a random 96-bit nonce value for AES-GCM, which does raise issues if you're encrypting large amounts of data under the same key. That is because the chance of collision with a 96-bit value is much higher. This choice was made due to the specific circumstances on which Chloride was designed to be used. Please be aware of this limitation for your own systems.
If you've discovered a security bug in Chloride, please email [John Downey](mailto:[email protected]).