Crypto4j is a java library for encrypt and decrypt values with Asymmetric and Symmetrical keys.
<dependency>
<groupId>io.github.mrspock182</groupId>
<artifactId>crypto4j</artifactId>
<version>1.0.1</version>
</dependency>
compile 'io.github.mrspock182:crypto4j:1.0.1'
implementation("io.github.mrspock182:crypto4j:1.0.1")
libraryDependencies += "io.github.mrspock182" % "crypto4j" % "1.0.1"
@Grapes(
@Grab(group='io.github.mrspock182', module='crypto4j', version='1.0.1')
)
'io.github.mrspock182:crypto4j:jar:1.0.1'
<dependency org="io.github.mrspock182" name="crypto4j" rev="1.0.1" />
[io.github.mrspock182/crypto4j "1.0.1"]
[![Maven Central](https://img.shields.io/maven-central/v/io.github.mrspock182/crypto4j.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.mrspock182%22%20AND%20a:%22crypto4j%22)
pkg:maven/io.github.mrspock182/[email protected]
maven_jar(
name = "crypto4j",
artifact = "io.github.mrspock182:crypto4j:1.0.1",
sha1 = "2252948eefb8ad5c547ee741a85e5865d9ef0383",
)
Obs: The version 1.0.0 have a problem with Asymmetric keys
Your key need 14 bytes to work.
import io.github.mrspock182.Encryption;
import io.github.mrspock182.constant.Cipher;
import io.github.mrspock182.constant.TypeEncryption;
import io.github.mrspock182.constant.Unicode;
import io.github.mrspock182.encryption.EncryptionSymmetrical;
Encryption encryption = new EncryptionSymmetrical(TypeEncryption.AES, Unicode.UTF8,
"{YOUR_KEY}", Cipher.PKCS5PADDING);
String encryptSymmetrical = encryption.encrypt("WORD TO ENCRYPT");
System.out.println(encryptSymmetrical);
import io.github.mrspock182.Decryption;
import io.github.mrspock182.constant.Cipher;
import io.github.mrspock182.constant.TypeEncryption;
import io.github.mrspock182.constant.Unicode;
import io.github.mrspock182.decryption.DecryptionSymmetrical;
Decryption decryption = new DecryptionSymmetrical(TypeEncryption.AES, Unicode.UTF8,
"{YOUR_KEY}", Cipher.PKCS5PADDING);
String decryptSymmetrical = decryption.toString("TIlt3ujfxpp_bLrOLL3S-A==");
System.out.println(decryptSymmetrical);
import io.github.mrspock182.GenerateKey;
import io.github.mrspock182.constant.TypeEncryption;
import io.github.mrspock182.generate.GenerateAsymmetricKey;
GenerateKey generate = new GenerateAsymmetricKey(TypeEncryption.RSA,
"{FILE_PATH}", {SIZE_KEY});
generateKey.generate();
import io.github.mrspock182.Encryption;
import io.github.mrspock182.constant.TypeEncryption;
import io.github.mrspock182.constant.Unicode;
import io.github.mrspock182.encryption.EncryptionAsymmetric;
Encryption encryption = new EncryptionAsymmetric(Unicode.UTF8,
TypeEncryption.RSA, "{FILE_PATH}/public.key");
String value = encryption.encrypt("WORD TO ENCRYPT");
System.out.println(encryptSymmetrical);
import io.github.mrspock182.Decryption;
import io.github.mrspock182.constant.TypeEncryption;
import io.github.mrspock182.constant.Unicode;
import io.github.mrspock182.decryption.DecryptionAsymmetric;
Decryption decryption = new DecryptionAsymmetric(Unicode.UTF8,
TypeEncryption.RSA, "{FILE_PATH}/private.key");
String value = decryption.toString("VALUE ENCRYPTED");
If our library needs to implement something new to solve your problem or wants to collaborate, send your pull request. If you find any error you can inform us through github issues
Please make sure to update tests as appropriate.