Git Product home page Git Product logo

spring-security-rsa's Introduction

This little project provides some RSA extensions to the base spring-security-crypto library. Currently supported: encryption and decryption with 2 algorithms wrapped up in the Spring Security Crypto interfaces TextEncryptor and BytesEncryptor. Example round trip:

TextEncryptor encryptor = new RsaSecretEncryptor();
String cipher = encryptor.encrypt("my message");
String message = encryptor.decrypt(cipher);

Above we create an encryptor with a random RSA key (the default constructor), and use it to encrypt and then decrypt a message. the default constructor is useful for testing, but for more durable use cases you can inject a private key or a KeyPair using the other constructors.

The encryption algorithm in the RsaSecretEncryptor is to generate a random 16-byte password, and use that to encrypt the message. The password is then itself RSA encrypted and prepended to the cipher text. The cipher test is base64 encoded (if using the TextEncryptor interface).

The other algorithm is in the RsaRawEncryptor which does raw RSA encryption on the whole message. We recommend the RsaSecretEncryptor.

N.B. if you need RSA signing and verification there are utilities already available in spring-security-jwt.

Important Prerequisites: to use Spring Security RSA you need the full-strength JCE installed in your JVM (it's not there by default). You can download the "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" from Oracle, and follow instructions for installation (essentially replace the 2 policy files in the JRE lib/security directory with the ones that you downloaded).

spring-security-rsa's People

Contributors

benkiefer avatar

Watchers

 avatar

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.