Android Key Create getKey(String keyRule)

Here you can find the source of getKey(String keyRule)

Description

get Key

License

Open Source License

Declaration

public static byte[] getKey(String keyRule) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.Key;

import javax.crypto.spec.SecretKeySpec;

public class Main {
    public static byte[] getKey(String keyRule) {
        Key key = null;/*from   ww w.jav  a  2  s  .  c  o  m*/
        byte[] keyByte = keyRule.getBytes();
        byte[] byteTemp = new byte[8];
        for (int i = 0; i < byteTemp.length && i < keyByte.length; i++) {
            byteTemp[i] = keyByte[i];
        }
        key = new SecretKeySpec(byteTemp, "DES");
        return key.getEncoded();
    }
}

Related

  1. createRandomKey(int size)
  2. generateKey(byte[] seed)
  3. generateKey(char[] passphraseOrPin, byte[] salt)
  4. generateKey(char[] passphraseOrPin, byte[] salt)
  5. generateMacSecret()
  6. getKeyFromPassphrase(String passphrase, byte[] salt)
  7. getKeyFromPassphrase(String passphrase, byte[] salt, int iterations)
  8. createDESedeKeySpec(SecretKey key)
  9. createSecretKey(byte[] rawkey)