Code Monkey home page Code Monkey logo

jackson-crypto's Introduction

Jackson Crypto

Build Status

Cryptographic utilities for Jackson.

Usage

To use this package from Maven, include the following dependency in your project:

<dependency>
  <groupId>com.meltmedia.jackson</groupId>
  <artifactId>jackson-crypto</artifactId>
  <version>0.2.0</version>
</dpendency>

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.