Examples of generateSecret()


Examples of javax.crypto.SecretKeyFactory.generateSecret()

        this.encryptedKey = encryptedKey;
        /* get SecretKey from encryptedKey */
        byte[] key = getDecrypted(encryptedKey, password);
        try {
            SecretKeyFactory keyFac = SecretKeyFactory.getInstance(CRYPTO_ALGORITHM);
            this.secretKey = keyFac.generateSecret(new DESedeKeySpec(key));;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

        /* Create PBE parameter set */
        pbeParamSpec = new PBEParameterSpec(salt, iteration_count);

        pbeKeySpec = new PBEKeySpec(password);
        keyFac = SecretKeyFactory.getInstance(PBE_ALGORITHM);
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        /* Create PBE Cipher */
        Cipher pbeCipher = Cipher.getInstance(PBE_ALGORITHM);

        /* Initialize PBE Cipher with key and parameters */
 
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, count);

        pbeKeySpec = new PBEKeySpec(PWD.toCharArray());
        keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

        // Initialize PBE Cipher with key and parameters
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

        // Create PBE parameter set
        pbeParamSpec = new PBEParameterSpec(salt, count);

        pbeKeySpec = new PBEKeySpec(PWD.toCharArray());
        keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

        // Initialize PBE Cipher with key and parameters
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

  public DESFactory(byte encKey[], byte desKey[]) throws Exception {
    SecureRandom sr = new SecureRandom();
    byte rawKeyData[] = encKey;
    DESKeySpec dks = new DESKeySpec(rawKeyData);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    enCipher = Cipher.getInstance("DES");
    enCipher.init(1, key, sr);
    rawKeyData = desKey;
    dks = new DESKeySpec(rawKeyData);
    key = keyFactory.generateSecret(dks);
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    enCipher = Cipher.getInstance("DES");
    enCipher.init(1, key, sr);
    rawKeyData = desKey;
    dks = new DESKeySpec(rawKeyData);
    key = keyFactory.generateSecret(dks);
    deCipher = Cipher.getInstance("DES");
    deCipher.init(2, key, sr);
  }

  public static String toHexString(byte value[]) {
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

  public byte[] doDecrypt(byte encryptText[]) throws Exception {
    SecureRandom sr = new SecureRandom();
    byte rawKeyData[] = desKey;
    DESKeySpec dks = new DESKeySpec(rawKeyData);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    Cipher cipher = Cipher.getInstance("DES");
    cipher.init(2, key, sr);
    byte encryptedData[] = encryptText;
    byte decryptedData[] = cipher.doFinal(encryptedData);
    return decryptedData;
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

  public byte[] doEncrypt(byte plainText[]) throws Exception {
    SecureRandom sr = new SecureRandom();
    byte rawKeyData[] = desKey;
    DESKeySpec dks = new DESKeySpec(rawKeyData);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    Cipher cipher = Cipher.getInstance("DES");
    cipher.init(1, key, sr);
    byte data[] = plainText;
    byte encryptedData[] = cipher.doFinal(data);
    return encryptedData;
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

      // 从原始密匙数据创建DESKeySpec对象
      DESKeySpec dks = new DESKeySpec(key);
      // 创建一个密匙工厂,然后用它把DESKeySpec转换成
      // 一个SecretKey对象
      SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(algorithm);
      SecretKey secretKey = keyFactory.generateSecret(dks);
      // Cipher对象实际完成加密操作
      enCipher = Cipher.getInstance(algorithm);
      deCipher = Cipher.getInstance(algorithm);
      // 用密匙初始化Cipher对象
      enCipher.init(Cipher.ENCRYPT_MODE, secretKey, sr);
View Full Code Here

Examples of javax.crypto.SecretKeyFactory.generateSecret()

   {
      // Create the PBE secret key
      cipherSpec = new PBEParameterSpec(salt, iterationCount);
      PBEKeySpec keySpec = new PBEKeySpec(keyStorePassword);
      SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEwithMD5andDES");
      cipherKey = factory.generateSecret(keySpec);
   }

   private void loadKeyAndTrustStore() throws Exception
   {
      if (keyStorePassword != null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.