https://github.com/phxql/easy-krypto
This Kotlin library aims to provide a simple way to encrypt and decrypt stuff in a secure manner.
https://github.com/phxql/easy-krypto
Last synced: 11 months ago
JSON representation
This Kotlin library aims to provide a simple way to encrypt and decrypt stuff in a secure manner.
- Host: GitHub
- URL: https://github.com/phxql/easy-krypto
- Owner: phxql
- License: lgpl-3.0
- Created: 2018-02-24T13:00:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T12:17:15.000Z (over 8 years ago)
- Last Synced: 2025-08-03T04:41:32.682Z (12 months ago)
- Language: Kotlin
- Size: 135 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Easy Krypto [](https://travis-ci.org/phxql/easy-krypto) [](https://maven-badges.herokuapp.com/maven-central/de.mkammerer.easy-krypto/easy-krypto)
This Kotlin library aims to provide a simple way to encrypt and decrypt stuff in a secure manner.
Using Java, Scala, Groovy, etc.? No problem, this library can also be used with any JVM language. See [Java interop](doc/java-interop.md) for details.
## Maven
```xml
de.mkammerer.easy-krypto
easy-krypto
1.0
```
## Usage
```kotlin
// We want to use symmetric crypto (same key for encrypting and decrypting)
val symmetric = EasyKrypto.symmetric()
// Generate a random key
val key = symmetric.keys.createRandom()
// Save that key to a file
val keyFile = Paths.get("/path/to/key")
key.saveToFile(keyFile)
// We can also load the key from the file again
val loadedKey = symmetric.keys.loadFromFile(keyFile)
// We create a plaintext from a string we want to encrypt
val plaintext = symmetric.plaintexts.createFromString("Hello EasyKrypto")
// And then we encrypt that plaintext with the key to the ciphertext
val ciphertext = symmetric.encrypt(plaintext, key)
// We can now store the ciphertext to a file and no one without the key can read it
val ciphertextFile = Paths.get("/path/to/ciphertext")
ciphertext.saveToFile(ciphertextFile)
// We can load the ciphertext from the file again
val loadedCiphertext = symmetric.ciphertexts.loadFromFile(ciphertextFile)
// And use the key to decrypt the ciphertext to the plaintext
val decrypted = symmetric.decrypt(loadedCiphertext, loadedKey)
// We can now print the decrypted string. This prints "Hello EasyKrypto"
println(decrypted.asString())
```
For more examples, [see the How-To guide](doc/howto.md).
## License
Licensed under [LGPLv3](https://www.gnu.org/licenses/lgpl-3.0.en.html).
## Developer guide
See [the developer guide](doc/development.md).