This repository has been archived by the owner. It is now read-only.
A utility library for dealing with cryptography in Java 1.8
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
Readme.md
pom.xml

Readme.md

Crypto Util

This library provides a set of classes that make using Java's crypto library easy. This library was written because the author got fed up with writing variations of the same code whenever he needed to deal with encryption.

Note: this library is developed against Java 1.8.

Example

Let's assume you need to encrypt the string "foobar" according to AES using the mode "AES/CBC/PKCS5Padding". Then the following will get you sorted:

// You should save this key in a secure location.
// You will need it for decryption.
Key key = KeyToolFactory.getInstance().aes128key().get();
AesCryptoTool tool = new AesCryptoTool(key);
Optional<EncryptedData> encryptedOptional =
  tool.encrypt("foobar".getBytes());

encryptedOptional.ifPresent(
  (encryptedData) -> {
    String json = encryptedData.toString();
    System.out.println(json);
  }
);

Install

This library is available as a Maven artifact. Simply add the dependency:

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<depdendencies>
  <dependency>
    <groupId>com.github.jsumners</groupId>
    <artifactId>crypto-util</artifactId>
    <version>0.3.0</version>
  </dependency>
</dependencies>

License

MIT License