Android Key Create generatePBEKey(char[] password, byte[] salt, String algorthm, int iterations, int keyLength)

Here you can find the source of generatePBEKey(char[] password, byte[] salt, String algorthm, int iterations, int keyLength)

Description

generate PBE Key

Declaration

private static SecretKey generatePBEKey(char[] password, byte[] salt,
            String algorthm, int iterations, int keyLength)
            throws NoSuchAlgorithmException, InvalidKeySpecException 

Method Source Code

//package com.java2s;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;

public class Main {
    private static SecretKey generatePBEKey(char[] password, byte[] salt,
            String algorthm, int iterations, int keyLength)
            throws NoSuchAlgorithmException, InvalidKeySpecException {
        SecretKeyFactory secretKeyFactory = SecretKeyFactory
                .getInstance(algorthm);/* ww w  . j  a va2s.com*/
        KeySpec keySpec = new PBEKeySpec(password, salt, iterations,
                keyLength);
        SecretKey secretKey = secretKeyFactory.generateSecret(keySpec);
        return secretKey;
    }
}

Related

  1. getKey(String keyRule)
  2. getKeyFromPassphrase(String passphrase, byte[] salt)
  3. getKeyFromPassphrase(String passphrase, byte[] salt, int iterations)
  4. createDESedeKeySpec(SecretKey key)
  5. createSecretKey(byte[] rawkey)
  6. generateSymmetricKey()
  7. getCipherFromPassphrase(String passphrase, byte[] salt, int iterations, int opMode)
  8. getCipherFromPassphrase(String passphrase, byte[] salt, int opMode)
  9. getMacForPassphrase(String passphrase, byte[] salt)