Giter VIP home page Giter VIP logo

cipherizy-lib's Introduction

cipherizy-lib

CI Renovate Version CLA assistant Licence

Cipher lib for Java, Kotlin or Scala projects.

This lib was developed with the main goal of make sensitive data encryption/decryption easy. To use, you need only to import it into your project using maven, gradle or sbt.

Getting Started

Import into your project.

Maven

<dependency>
 <groupId>io.github.felipebonezi</groupId>
 <artifactId>cipherizy-lib</artifactId>
 <version>X.Y.Z</version>
 <type>pom</type>
</dependency>

Gradle

implementation 'io.github.felipebonezi:cipherizy-lib:X.Y.Z'

Sbt

  libraryDependencies ++= "io.github.felipebonezi" % "cipherizy-lib" % "X.Y.Z"

First Cipher

It is too easy to encrypt and decrypt data using this lib.

There is a factory class - i.e. CipherFactory - that creates the encription classes who will be responsible to generade the algorythns.

There is a cipher interface - i.e. ICipher- that you will use to encript your data in different algorithms (e.g. AES).

Encrypt

CipherFactory factory = CipherFactory.getIntance();
ICipher cipher = factory.get(CipherFactory.Algorithm.AES);

// To encrypt your data.
try {
  byte[] key  = getKey();  // Generate your own randomic key (must be 32 bytes long).
  byte[] salt = getSalt(); // Get your encryption salt (must be 16 bytes long).
  byte[] data = getData(); // Get your data in byte[] format.
  
  byte[] encrypted = cipher.encrypt(key, salt, data);
  System.out.println(new String(encrypted))
} catch (CipherException e) {
  // There was an error to encrypt your data.
  e.printStackTrace();
}

Decrypt

CipherFactory factory = CipherFactory.getIntance();
ICipher cipher = factory.get(CipherFactory.Algorithm.AES);

// To decrypt your data.
try {
  byte[] key  = getKey();  // Get your encryption key (must be 32 bytes long).
  byte[] salt = getSalt(); // Get yor encryption salt (must be 16 bytes long).
  byte[] data = getData(); // Get your encrypted data in byte[] format.
  
  byte[] decrypted = cipher.decrypt(key, salt, data);
  System.out.println(new String(decrypted))
} catch (CipherException e) {
  // There was an error to decrypt your data.
  e.printStackTrace();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.