Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meltmedia/jackson-crypto
Cryptographic utilities for Jackson
https://github.com/meltmedia/jackson-crypto
cryptography encryption jackson java json
Last synced: 8 days ago
JSON representation
Cryptographic utilities for Jackson
- Host: GitHub
- URL: https://github.com/meltmedia/jackson-crypto
- Owner: meltmedia
- Created: 2014-10-12T02:56:32.000Z (about 10 years ago)
- Default Branch: develop
- Last Pushed: 2016-10-11T21:52:47.000Z (about 8 years ago)
- Last Synced: 2024-04-14T14:14:26.533Z (7 months ago)
- Topics: cryptography, encryption, jackson, java, json
- Language: Java
- Size: 86.9 KB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Jackson Crypto
[![Build Status](https://travis-ci.org/meltmedia/jackson-crypto.svg?branch=develop)](https://travis-ci.org/meltmedia/jackson-crypto)
Cryptographic utilities for Jackson.
## Usage
To use this package from Maven, include the following dependency in your project:
```
com.meltmedia.jackson
jackson-crypto
0.2.0```
Then create a new CryptoModule and register it with your ObjectMapper.
```
EncryptionService service = ...;
ObjectMapper mapper = ...;
mapper.registerModule(new CryptoModule().addSource(service));
```Once this is done, you can use the `@Encrypted` annotation on your `@JsonProperty` annotated methods to encrypt them during serialization and
decrypt them during deserialization. So, a POJO like the following:```
public class Pojo {
protected String secret;@JsonProperty
@Encrypted
public String getSecret() {
return this.secret;
}public void setSecret( String secret ) {
this.secret = secret;
}
}
```will serialize into JSON like:
```
{
"secret": {
"salt": "tKD8wQ==",
"iv": "s9hTJRaZn6fxxpA4nVfDag==",
"value": "UZENJOltf+9EZS03AXbmeg==",
"cipher": "aes-256-cbc",
"keyDerivation": "pbkdf2",
"keyLength": 256,
"iterations": 2000
}
}
```## Example
This project does not yet have its own example project, but you can see an example of using this library in the [Dropwizard Crypto example project](https://github.com/meltmedia/dropwizard-crypto/tree/develop/example).