Files
nio-crypto/README.md
2021-02-18 15:53:51 -05:00

2.5 KiB
Executable File

Java New I/O Crypto Library

The official distributions of Java include cryptographic functions in a framework called the Java Cryptography Extension (JCE). JCE provides the API layer and corresponding implementations of cryptographic functions like key generation, key storage/retrieval, and cipher encryption/decryption. The JCE API supports those basic functions along with Java I/O based capabilities using InputStream and OutputStream implementations.

Since the introduction of JCE, Java has introduced the "Non-blocking I/O" (NIO) framework as a complement to the Java (blocking) I/O framework. It has huge advantages in performance for many applications. For instance, it is recommended that Apache Tomcat configurations use NIO connectors for clients due to its performance advantages.

Using

Including

To use this library, you must include it as a dependency to your project. An example configuration for Apache Maven is provided below. Either set the inteligr8.nio-crypto.version as a property or replace it with a valid version.

<project ..>
	...
	<dependencies>
		...
		<dependency>
			<groupId>com.inteligr8</groupId>
			<artifactId>nio-crypto</artifactId>
			<version>${inteligr8.nio-crypto.version}</version>
		</dependency>
		...
	</dependencies>
	...
</project>

Developing

There are many different algorithms that are available for encrypting and decrypting content. This project does not care about those details. It does not care about key generation, storage, or retrieval. It only cares about the streaming of content through a cipher. The default set of algorithms come from the JVM default JCE provider. You can include other JCE providers that provide the same, similar, and completely new algorithms. Some of those providers interface directly with hardware or the network for enhanced security or performance.

A cipher is defined by an algorithm, cipher mode, and padding. These are married together into a single parameter in JCE called a transformation. That same parameter is used in this library. You will also need an appropriate key and your content.

You can find sample code for common algorithms in the source.