Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fernandospr/jvm-encryption-sample
Encryption samples for a Kotlin application.
https://github.com/fernandospr/jvm-encryption-sample
aes rsa
Last synced: 5 days ago
JSON representation
Encryption samples for a Kotlin application.
- Host: GitHub
- URL: https://github.com/fernandospr/jvm-encryption-sample
- Owner: fernandospr
- Created: 2022-06-27T14:50:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-27T15:37:36.000Z (over 2 years ago)
- Last Synced: 2024-11-08T10:50:42.418Z (about 2 months ago)
- Topics: aes, rsa
- Language: Kotlin
- Homepage:
- Size: 63.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jvm-encryption-sample
Encryption samples.
## AES
Open/modify `AesApp.kt` and run the `main` function.You'll get the following (similar) output:
```
AES KEY GENERATION
Key (Base64): fLivmIofMNx1S0vx4yorqerF26rw8T7tF54HC/UldjY=
IV (Base64): 8NV+Jf/TU2JB+qIgSw2aHw==AES ENCRYPTION
Key (Base64): fLivmIofMNx1S0vx4yorqerF26rw8T7tF54HC/UldjY=
IV (Base64) - Optional: 8NV+Jf/TU2JB+qIgSw2aHw==
Message: Hello world!
Encrypted message (Base64): upqRbjPahMIfMDSI/my7cA==
IV (Base64): 8NV+Jf/TU2JB+qIgSw2aHw==AES DECRYPTION
Key (Base64): fLivmIofMNx1S0vx4yorqerF26rw8T7tF54HC/UldjY=
IV (Base64): 8NV+Jf/TU2JB+qIgSw2aHw==
Encrypted message (Base64): upqRbjPahMIfMDSI/my7cA==
Decrypted message: Hello world!
```## RSA
Open/modify `RsaApp.kt` and run the `main` function.You'll get the following (similar) output:
```
RSA KEY GENERATION
PubKey (Base64): MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsIHPP8+QJmFKTIjMGFfguQCDXDx9BzGxF5Js8OSqNSPtaskO+M2GRf2Gv9m0O16wixsSN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