Skip to content

An example of how to encrypt and decrypt entity fields with JPA converters and Spring Data JPA

Notifications You must be signed in to change notification settings

damienbeaufils/spring-data-jpa-encryption-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-data-jpa-encryption-example

Build Status

An example of how to encrypt and decrypt entity fields with JPA converters and Spring Data JPA. See blog post.

Requirements

Java 11

How is encryption enabled

Entity

There is a User entity which have different fields: id, firstName, lastName, email, birthDate and creationDate.

All fields except id are encrypted in database using AES algorithm.

Repository

There is a simple UserRepository which extends Spring Data JpaRepository.

Converters

Encryption is enabled on fields using different JPA converters: StringCryptoConverter, LocalDateCryptoConverter and LocalDateTimeCryptoConverter. This is verified with UserRepositoryTest integration test.

All converters are unit tested.

Encryption key

Encryption key is empty by default (see example.database.encryption.key configuration key in application.yml).

You have to provide an encryption key in configuration or specify it in options when running application.

Run tests

./gradlew check

About

An example of how to encrypt and decrypt entity fields with JPA converters and Spring Data JPA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages