Example usage for android.security.keystore KeyProperties DIGEST_SHA512

List of usage examples for android.security.keystore KeyProperties DIGEST_SHA512

Introduction

In this page you can find the example usage for android.security.keystore KeyProperties DIGEST_SHA512.

Prototype

String DIGEST_SHA512

To view the source code for android.security.keystore KeyProperties DIGEST_SHA512.

Click Source Link

Document

SHA-2 512 (aka SHA-512) digest.

Usage

From source file:Main.java

@TargetApi(Build.VERSION_CODES.M)
private static void generateNewKey() {
    try {//from w w w.j a v a 2 s  . c o m
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA,
                KEY_PROVIDER);

        keyPairGenerator.initialize(new KeyGenParameterSpec.Builder(KEY_ALIAS, KeyProperties.PURPOSE_DECRYPT)
                .setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA512)
                .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_OAEP).build());
        keyPairGenerator.generateKeyPair();

    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (NoSuchProviderException e) {
        e.printStackTrace();
    } catch (InvalidAlgorithmParameterException e) {
        e.printStackTrace();
    }
}