Created
November 9, 2016 02:04
-
-
Save itang/49344e8a68feb9c8cb174ad19b41089f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package demo | |
| import java.security.SecureRandom | |
| import java.util.* | |
| import javax.crypto.KeyGenerator | |
| fun main(args: Array<String>) { | |
| val kgs = listOf(KeyGenerator.getInstance("AES").apply { init(SecureRandom()) }, | |
| KeyGenerator.getInstance("AES").apply { init(128) }) | |
| for (kg in kgs) { | |
| val key = kg.generateKey() | |
| val content = String(Base64.getUrlEncoder().encode(key.encoded)) | |
| println(content + " " + content.length) | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment