Giter Club home page Giter Club 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();
}

cipherizy-lib's People

Contributors

felipebonezi avatar matheusnascgomes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cipherizy-lib's Issues

Encrypt/Decrypt `java.io.File`

Is your feature request related to a problem? Please describe.
We could provide an easy way to encrypt/decrypt java.io.File.

Describe the solution you'd like
Implement AES java.io.File encryption/decryption.

Additional context
You could use Baeldung sample as a guide.

Implement Base16, Base32 and Base64 cryptography encode and decode

Is your feature request related to a problem? Please describe.
I'm frustrated to use another library to encrypt/decrypt Base64 and it has problems using Base16 and Base32 that isn't so popular.

Describe the solution you'd like
Implement RFC-4648 for Base16, Base32 and Base64.

Describe alternatives you've considered
We could use other lightweight dependencies but I encourage implementing by ourselves.

Bouncy Castle:
https://www.bouncycastle.org/

Guava:
https://guava.dev/releases/17.0/api/docs/com/google/common/io/BaseEncoding.html

Apache:
https://commons.apache.org/proper/commons-codec/apidocs/org/apache/commons/codec/binary/Base16.html

Refactor `ICipher` interface to be more generic with key/salt specs

Is your feature request related to a problem? Please describe.
We have only AES cryptography that depends on key/salt to be encrypted/decrypt but there's another encryption algorithm that doesn't need. We must provide a better structure to be more generic and satisfy both (and others) encryption algorithms.

Describe the solution you'd like
We could provide a DTO to pass encryption parameters.

Additional context
This issue could be considered as a Breaking Change problem.

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.