Android AES Key Get getRawKey(String key)

Here you can find the source of getRawKey(String key)

Description

get Raw Key

Declaration

private static byte[] getRawKey(String key) throws Exception 

Method Source Code

//package com.java2s;
import java.security.SecureRandom;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class Main {
    private static byte[] getRawKey(String key) throws Exception {
        KeyGenerator kgen = KeyGenerator.getInstance("AES");
        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
        sr.setSeed(key.getBytes());/*from  w  ww .  jav a  2  s.  com*/
        kgen.init(256, sr);
        SecretKey skey = kgen.generateKey();
        return skey.getEncoded();
    }
}

Related

  1. createKey(String password)
  2. getKeyBytes(String key)
  3. getRawKey(byte[] seed)
  4. getRawKey(byte[] seed)
  5. getRawKey(byte[] seed)
  6. getRawKey(byte[] seed)