Last active
November 7, 2017 08:47
-
-
Save yakivmospan/35a4498458485803f22293d46d745718 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
fun createAndroidKeyStoreAsymmetricKey(alias: String): KeyPair { | |
val generator = KeyPairGenerator.getInstance("RSA", "AndroidKeyStore") | |
if (SystemServices.hasMarshmallow()) { | |
initGeneratorWithKeyGenParameterSpec(generator, alias) | |
} else { | |
initGeneratorWithKeyPairGeneratorSpec(generator, alias) | |
} | |
// Generates Key with given spec and saves it to the KeyStore | |
return generator.generateKeyPair() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment