Android AES Key Get toKey(byte[] key)

Here you can find the source of toKey(byte[] key)

Description

transfer secret key

Parameter

Parameter Description
key binary secret key

Return

secret key

Declaration

private static Key toKey(byte[] key) 

Method Source Code

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

import javax.crypto.spec.SecretKeySpec;

public class Main {
    /**//w  w w  . j a  v a  2  s  .  co  m
     * Secret Key algorithms
     */
    private static final String KEY_ALGORITHM = "AES";

    /**
     * transfer secret key
     *
     * @param key   binary secret key
     * @return secret key
     */
    private static Key toKey(byte[] key) {
        //create secret key
        return new SecretKeySpec(key, KEY_ALGORITHM);
    }
}

Related

  1. getSecretKey(String key)
  2. initSecretKey()
  3. keyAreEqual(byte[] b1, byte[] b2)
  4. makeKey()
  5. makeKey(String passkey)
  6. generateEncryptionSecret()