Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

jsumners/crypto-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A utility library for dealing with cryptography in Java 1.8

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages