jncryptor

A Java library that simplifies encrypting data securely with AES.

License

License

GroupId

GroupId

org.cryptonode.jncryptor
ArtifactId

ArtifactId

jncryptor
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

jncryptor
A Java library that simplifies encrypting data securely with AES.
Project URL

Project URL

https://github.com/RNCryptor/JNCryptor

Download jncryptor

How to add to project

<!-- https://jarcasting.com/artifacts/org.cryptonode.jncryptor/jncryptor/ -->
<dependency>
    <groupId>org.cryptonode.jncryptor</groupId>
    <artifactId>jncryptor</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.cryptonode.jncryptor/jncryptor/
implementation 'org.cryptonode.jncryptor:jncryptor:1.2.0'
// https://jarcasting.com/artifacts/org.cryptonode.jncryptor/jncryptor/
implementation ("org.cryptonode.jncryptor:jncryptor:1.2.0")
'org.cryptonode.jncryptor:jncryptor:jar:1.2.0'
<dependency org="org.cryptonode.jncryptor" name="jncryptor" rev="1.2.0">
  <artifact name="jncryptor" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.cryptonode.jncryptor', module='jncryptor', version='1.2.0')
)
libraryDependencies += "org.cryptonode.jncryptor" % "jncryptor" % "1.2.0"
[org.cryptonode.jncryptor/jncryptor "1.2.0"]

Dependencies

test (3)

Group / Artifact Type Version
commons-io : commons-io jar 2.4
org.apache.commons : commons-lang3 jar 3.2.1
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

JNCryptor

JNCryptor is an easy-to-use library for encrypting data with AES. It was ported to Java from the RNCryptor library for iOS.

The project is considered finished, hence the lack of recent activity. Please raise issues for any problems encountered.

Getting JNCryptor

The Javadocs can be browsed online: JNCryptor Javadocs.

You can download binaries, documentation and source from the Releases page. Maven users can copy the following snippet to retrieve the artifacts from Maven Central:

<dependency>
    <groupId>org.cryptonode.jncryptor</groupId>
    <artifactId>jncryptor</artifactId>
    <version>1.2.0</version>
</dependency>

Using JNCryptor

A quick example is shown below:

JNCryptor cryptor = new AES256JNCryptor();
byte[] plaintext = "Hello, World!".getBytes();
String password = "secretsquirrel";

try {
  byte[] ciphertext = cryptor.encryptData(plaintext, password.toCharArray());
} catch (CryptorException e) {
  // Something went wrong
  e.printStackTrace();
}

Android

Users have reported significant performance issues when using this library in Android (see Issue #23 for more info).

Android is not a tested nor supported platform for JNCryptor and there are no plans to address these performance issues. Please take a look at other projects, such as https://github.com/TGIO/RNCryptorNative, which aim to plug this gap with native code solutions.

IMPORTANT: Due to a bug in the Android SecureRandom implementation, JNCryptor is not currently safe to use in Android versions prior to 4.4. Please see an announcement from Google from back in 2013. The issue is tracked here as Issue #25, but will not be fixed in this project.

Iterations

JNCryptor supports changing the number of PBKDF2 iterations performed by the library. Unfortunately, the number of iterations is not currently encoded in the data format, which means that both sides of the conversation need to know how many iterations have been used.

Data Format

A proprietary data format is used that stores the IV, salt values (if applicable), ciphertext and HMAC value in a compact fashion. Methods are offered to encrypt data based on either an existing key, or a password. In the latter case, a key is derived from the password using a key derivation function, with 10,000 iterations and a salt valu.e

See the spec documents online.

Keys are derived from the password and the appropriate salt value using the PBKDF2 function with SHA1. A separate key is generated for encrypting the plaintext and computing the HMAC.

History

The data format supported by this library is v3. Both v1 and v0 have a significant security flaw whereby only the ciphertext was included in the HMAC value. There are no plans to support v1 or v0. v2 was deprecated due to a multi-byte password issue discovered in the objective-c implementation.

org.cryptonode.jncryptor
AES file format with implementations in many languages.

Versions

Version
1.2.0
1.1.0
1.0.1
1.0.0
0.5
0.4
0.3
0.2
0.1