https://github.com/antonsjava/sprops
Password protected property files
https://github.com/antonsjava/sprops
Last synced: 6 months ago
JSON representation
Password protected property files
- Host: GitHub
- URL: https://github.com/antonsjava/sprops
- Owner: antonsjava
- License: apache-2.0
- Created: 2019-03-29T14:09:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-12-15T20:34:49.000Z (about 4 years ago)
- Last Synced: 2025-03-27T18:19:51.005Z (9 months ago)
- Language: Java
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sprops
sprops is small library for encoding and decoding property files or simple
string data.
Motivation for this project was to have possibility to store secret data like passwords
together with sources or have it stored somewhere else publicly.
Property file with encoded properties are protected with one password. This must be
provided 'secretly' but this one only.
## sprops-tool
This is command line tool for manipulating the property files. Tool can be build by
building this project.
Than you can use it for encoding and decoding properties in property file
Lets have simple property file like
```
main.db.password=xxxx
email.server.password=yyyy
```
than you can call
```
/tmp/aaa> java -jar sprops-tool.jar -fencode passwords.properties main.db.password
INF main command to execute FileEncodeCommand
Enter password:
INF c.fenc Property: 'main.db.password'
INF c.fenc Encoding string from: 'xxxx'
INF c.fenc to: 'sprops:AAAAIBnzWe9H8rJtXVsOtBApsVC74BldooOGHOu4h1GJWuMpMpWXnD3b/vYurPjmHYM1Ww=='
INF main command FileEncodeCommand execution done.
```
and property looks like
```
main.db.password=sprops:AAAAIBnzWe9H8rJtXVsOtBApsVC74BldooOGHOu4h1GJWuMpMpWXnD3b/vYurPjmHYM1Ww==
email.server.password=yyyy
```
you can than call
```
/tmp/aaa> java -jar sprops-tool.jar -fdecode passwords.properties main.db.password
INF main command to execute FileDecodeCommand
Enter password:
INF c.fdec Property: 'main.db.password'
INF c.fdec Encoding string from: 'sprops:AAAAIBnzWe9H8rJtXVsOtBApsVC74BldooOGHOu4h1GJWuMpMpWXnD3b/vYurPjmHYM1Ww=='
INF c.fdec to: 'xxxx'
INF main command FileDecodeCommand execution done.
```
and property looks like
```
main.db.password=xxxx
email.server.password=yyyy
```
There are also other options you can see it with --help option.
## Property file usage
Encoded file can be used in application
```java
String password = .....
Properties encodedProps = .....
PropertiesEncoder encoder = PropertiesEncoder.instance(password);
encoder.add(encodedProps);
String decodedProperty = encoder.getProperty("property.name");
Properties decodedProps = encoder.decode();
```
## Simple encoding/decoding
You can use
```java
String password = .....
String text = .....
SimpleEncoder encoder = SimpleEncoder.instance(password);
String encodedString = encoder.encode(text);
String decodedString = encoder.decode(encodedString);
```
## System properties utility
If you are using spring boot and you want to have encoded properties provide as
SB property. An easy way is copy the properties to System properties at wery
first moment of starting application
```java
Properties props = .....
SystemPropertiesUpdater.instance(props)
.map("main.db.password", "spring.datasource.password")
.map("email.server.password", "myapp.notifier.password");
```
## Maven usage
```
io.github.antonsjava
sprops
LATESTVERSION
```