Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elomagic/spps-jshiro
Simple Password Protection Solution for Java with Apache Shiro
https://github.com/elomagic/spps-jshiro
aes aes-256 aes-256-gcm aes-gcm decryption encryption gcm java password secret
Last synced: about 16 hours ago
JSON representation
Simple Password Protection Solution for Java with Apache Shiro
- Host: GitHub
- URL: https://github.com/elomagic/spps-jshiro
- Owner: elomagic
- License: apache-2.0
- Created: 2021-02-01T16:06:25.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-19T08:14:30.000Z (almost 3 years ago)
- Last Synced: 2024-01-29T23:14:10.059Z (9 months ago)
- Topics: aes, aes-256, aes-256-gcm, aes-gcm, decryption, encryption, gcm, java, password, secret
- Language: Java
- Homepage:
- Size: 118 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# spps-jshiro
Simple Password Protection Solution for Java with Apache Shiro
---
[![GitHub tag](https://img.shields.io/github/tag/elomagic/spps-jshiro.svg)](https://GitHub.com/elomagic/spps-jshiro/tags/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Build Status](https://img.shields.io/travis/com/elomagic/spps-jshiro)](https://travis-ci.com/github/elomagic/spps-jshiro)
[![Coverage Status](https://coveralls.io/repos/github/elomagic/spps-jshiro/badge.svg)](https://coveralls.io/github/elomagic/spps-jshiro)
[![GitHub issues](https://img.shields.io/github/issues-raw/elomagic/spps-jshiro)](https://github.com/elomagic/spps-jshiro/issues)The SPPS is a lightweight solution to protect / hide your password or anything else from your code.
## Features
* AES 256 GCM en-/decryption
* Cross programming languages support ([Java](https://github.com/elomagic/spps-jbc), [Python](https://github.com/elomagic/spps-py), [Node.js](https://github.com/elomagic/spps-npm))## Concept
This solution helps you to accidentally publish secrets unintentionally by splitting the secret into an encrypted part and a private key.
The private key is kept separately from the rest, in a secure location for the authorized user only.The private key is randomized for each user on each system and is therefore unique. This means that if someone has the encrypted secret,
they can only read it if they also have the private key. You can check this by trying to decrypt the encrypted secret with another user or another system. You will not succeed.A symmetrical encryption based on the AES-GCM 256 method is used. See also https://en.wikipedia.org/wiki/Galois/Counter_Mode
By default, the private key is stored in a file "/.spps/settings" of the user home folder.
Keep in mind that anyone who has access to the user home or relocation folder also has access to the private key !!!!
## Using in your Maven project
Add following dependency to your project
```xml
...
de.elomagic
spps-jshiro
1.1.0
...
```
## Example
```java
import de.elomagic.spps.jshiro.SimpleCrypt;class Sample {
void testEncryptDecryptWithString() throws Exception {
String value = "My Secret";String encrypted = SimpleCrypt.encrypt(value);
System.out.println("My encrypted secret is " + encryptedSecret);
String decrypted = SimpleCrypt.decryptToString(encrypted);
System.out.println("...and my secret is " + decrypted);
}
}
```## How to create a private key
### Create a private in your home folder:
Enter following command in your terminal:
```bash
java -jar spps-jshiro-1.0.0.jar -CreatePrivateKey
```The settings file ```'~/.spps/settings'``` in your home folder will look like:
```properties
key=5C/Yi6+hbgRwIBhXT9PQGi83EVw2Oe6uttRSl4/kLzc=
relocation=
```### Alternative, create a private key on a removable device:
Enter following command in your terminal:
```bash
java -jar spps-jshiro-1.0.0.jar -CreatePrivateKey -Relocation /Volumes/usb-stick
```The settings file ```'~/.spps/settings'``` in your home folder will look like:
```properties
key=
relocation=/Volumes/usb-stick
```...and in the relocation folder look like:
```properties
key=5C/Yi6+hbgRwIBhXT9PQGi83EVw2Oe6uttRSl4/kLzc=
relocation=
```## How to create an encrypted password
Enter following command in your terminal:
```bash
java -jar spps-jshiro-1.0.0.jar -Secret YourSecret
```Output should look like:
```
{MLaFzwpNyKJbJSCg4xY5g70WDAKnOhVe3oaaDAGWtH4KXR4=}
```## How can my application use an alternative settings file instead of the default
*Supported since version 1.1.0*
The method ```SimpleCrypt.setSettingsFile([file])``` can be used to set application wide an alternative settings file instead of "/.spps/settings" in the
users home folder.```java
import de.elomagic.spps.bc.SimpleCrypt;import java.nio.file.Paths;
class Sample {
void testEncryptDecryptWithString() throws Exception {
SimpleCrypt.setSettingsFile(Paths.get("./configuration/privateKey"));String decrypted = SimpleCrypt.decryptToString(SimpleCrypt.encrypt("secret"));
System.out.println("...and my secret is " + decrypted);
}}
```## Contribution
### Releasing new version / hotfix (Only for users who have repository permissions)
Steps for release a new version / hotfix
```bash
mvn clean install release:prepare -P release
mvn release:perform -P release
```