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

jsumners/crypto-util

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

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

No packages published

Languages