Skip to content

Instantly share code, notes, and snippets.

@d0nutptr
Last active July 4, 2017 00:41
Show Gist options
  • Select an option

  • Save d0nutptr/88f80a329b40790a4ac0456434bfe8da to your computer and use it in GitHub Desktop.

Select an option

Save d0nutptr/88f80a329b40790a4ac0456434bfe8da to your computer and use it in GitHub Desktop.
KeyGenerator generator = KeyGenerator.getInstance("AES", "AndroidKeyStore");
generator.init(new KeyGenParameterSpec.Builder("MyEncryptionKey", KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_GCM)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.setRandomizedEncryptionRequired(true)
.setKeySize(256)
.build(), new SecureRandom());
generator.generateKey();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment