Spring Hibernate Entity Encryption

An entity encryption library that seamlessly encrypts when stored to database and decrypts when it is fetched.

Лицензия

Лицензия

Категории

Категории

Hibernate Данные ORM
Группа

Группа

com.github.mekuanent
Идентификатор

Идентификатор

spring-hibernate-entity-encryption
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spring Hibernate Entity Encryption
An entity encryption library that seamlessly encrypts when stored to database and decrypts when it is fetched.
Ссылка на сайт

Ссылка на сайт

https://github.com/mekuanent/SpringHibernateEntityEncryption
Система контроля версий

Система контроля версий

http://github.com/mekuanent/SpringHibernateEntityEncryption/tree/master

Скачать spring-hibernate-entity-encryption

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.mekuanent/spring-hibernate-entity-encryption/ -->
<dependency>
    <groupId>com.github.mekuanent</groupId>
    <artifactId>spring-hibernate-entity-encryption</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mekuanent/spring-hibernate-entity-encryption/
implementation 'com.github.mekuanent:spring-hibernate-entity-encryption:1.0.1'
// https://jarcasting.com/artifacts/com.github.mekuanent/spring-hibernate-entity-encryption/
implementation ("com.github.mekuanent:spring-hibernate-entity-encryption:1.0.1")
'com.github.mekuanent:spring-hibernate-entity-encryption:jar:1.0.1'
<dependency org="com.github.mekuanent" name="spring-hibernate-entity-encryption" rev="1.0.1">
  <artifact name="spring-hibernate-entity-encryption" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mekuanent', module='spring-hibernate-entity-encryption', version='1.0.1')
)
libraryDependencies += "com.github.mekuanent" % "spring-hibernate-entity-encryption" % "1.0.1"
[com.github.mekuanent/spring-hibernate-entity-encryption "1.0.1"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-web jar 2.1.6.RELEASE
org.springframework.boot : spring-boot-starter-data-jpa jar 2.1.6.RELEASE

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

Spring Entity Encryption

This library will allow you to to easily store data in encrypted format. It will store the attributes of your choice encrypted in your database and gives you the decrypted version when you need to read it.

Here's the Loopback version of the library https://github.com/mekuanent/loopback-encryption-mixin

Installation

For maven based projects

<dependency>
  <groupId>com.github.mekuanent</groupId>
  <artifactId>spring-hibernate-entity-encryption</artifactId>
  <version>1.0.0</version>
</dependency>

For gradle based projects

implementation 'com.github.mekuanent:spring-hibernate-entity-encryption:1.0.0'

You can check out this url for other builds https://search.maven.org/artifact/com.github.mekuanent/spring-hibernate-entity-encryption/1.0.0/jar

Setup

Add the following annotation to import the encryption configuration class.

...
@Import(EnableEncryptionConfig.class)
public class Application {
...

After that you need to specify your encryption key, salt,... globally. To do that you need to write the following in your application's main method.

EncryptionHandler.set(new PBEHandler("<your password>",
                "<your salt>", "<your IV>", <iteration>, 
                <derived key length (optional with default 256)>));

Next, put @Encrypted annotation on all fields of the entities you want to be encrypted when stored.

E.g.

@Encrypted
private String title;

That's it, you're all set.

Custom Encryption Algorithm

If you don't want to use the default encryption scheme. you can define your own by creating an @Component annotated class implementing IEncryptionHandler

E.g.

@Component
public class CustomEncryptionHandler implements IEncryptionHandler {

    @Override
    public String encrypt(String raw) {}
    
    @Override
    public String decrypt(String cipherText) {}

}

There are two ways of setting your custom encryption handler,

setting handler Globally

you can set it up in the main method of your application.

EncryptionHandler.set(new CustomEncryptionHandler("<your password>",
                "<your salt>", "<your IV>", <iteration>, 
                <derived key length (optional with default 256)>));

setting handlers for every field

In this case, your custom encryption handler is required to have an empty constructor.

You can set your handler to the field of your choice by just including it as a handler parameter

E.g.

@Encrypted(handler = CustomEncryptionHandler.class)
private String description;

Resources

you can checkout the complete sample application here: https://github.com/mekuanent/SpringEntityEncryptionLibExample

License

Spring Hibernate Entity Encryption is released under the terms of the Apache Software License Version 2.0 (see license.txt).

Версии библиотеки

Версия
1.0.1
1.0.0