Skip to content

vitamaxDH/field-cryptor-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Field-Cryptor-Java

  • Field-Cryptor is to help developers encrypt / decrypt designated field values conveniently
  • Supported cryptographic algorithms are listed below
    • AES/CBC/NoPadding (128)
    • AES/CBC/PKCS5Padding (128)
    • AES/ECB/NoPadding (128)
    • AES/ECB/PKCS5Padding (128)
    • [TBD] DES/CBC/NoPadding (56)
    • [TBD] DES/CBC/PKCS5Padding (56)
    • [TBD] DES/ECB/NoPadding (56)
    • [TBD] DES/ECB/PKCS5Padding (56)
    • [TBD] DESede/CBC/NoPadding (168)
    • [TBD] DESede/CBC/PKCS5Padding (168)
    • [TBD] DESede/ECB/NoPadding (168)
    • [TBD] DESede/ECB/PKCS5Padding (168)
    • [TBD] RSA/ECB/PKCS1Padding (1024, 2048)
    • [TBD] RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048)
    • [TBD] RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048)

by Oracle Cipher API

v0.0.1


Examples

  1. Put @FieldCrypto annotation on fields you want to encrypt/decrypt.
import com.max.fieldcryptor.annot.FieldCrypto;

public class Person {

    @FieldCrypto
    String name;
    String address;
    int age;
}
  1. Add crypto properties to create a cipher
String cipherName = "Field-Cryptor";
CryptographicAlgorithm algorithm = CryptographicAlgorithm.AES_CBC_PKCS5_PADDING;
String key = "sampleAESKeyForDemoItIsEasyToUse";
String iv = "sampleCBCinitVec";

CipherFactory.addCipher(cipherKeyName, algorithm, key, iv, true);
  1. Get the cipher from FieldCryptorFactory and encrypt / decrypt
AbstractCipher cipher = CipherFactory.getCipher(cipherKeyName);
Person person = new Person("VitaMax", "Suwon", 50);

FieldCryptor fieldCryptor = FieldCryptor.from(cipher);
Person encryptedObj = fieldCryptor.encrypt(person, Person::new);
Person decryptedObj = fieldCryptor.decrypt(encryptedObj, Person::new);
  1. Check the result
System.out.println("encryptedObj = " + encryptedObj);
System.out.println("decryptedObj = " + decryptedObj);

encryptedObj = Person{name='ocWec2FvMBH7ytkZaQTbgw==', address='Suwon', age=50}

decryptedObj = Person{name='VitaMax', address='Suwon', age=50}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages