Examples of doFinal()


Examples of javax.crypto.Cipher.doFinal()

      throw new XMLEncryptionException("empty", ike);
    }

        try {
            encryptedBytes =
                c.doFinal(serializedOctets.getBytes("UTF-8"));

            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Expected cipher.outputSize = " +
                Integer.toString(c.getOutputSize(
                    serializedOctets.getBytes().length)));
            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Actual cipher.outputSize = " +
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

            throw new XMLEncryptionException("empty", ike);
        }
       
        try {
            encryptedBytes =
                    c.doFinal(serializedOctets);
           
            logger.log(java.util.logging.Level.FINE, "Expected cipher.outputSize = " +
                    Integer.toString(c.getOutputSize(
                    serializedOctets.length)));
            logger.log(java.util.logging.Level.FINE, "Actual cipher.outputSize = " +
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

    }

    byte[] plainBytes;

        try {
            plainBytes = c.doFinal(encryptedBytes,
                   ivLen,
                   encryptedBytes.length - ivLen);

        } catch (IllegalBlockSizeException ibse) {
            throw new XMLEncryptionException("empty", ibse);
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

        try {
            /* Create PBE Cipher */
            Cipher pbeCipher = getCipher(Cipher.ENCRYPT_MODE, password);
            /* Encrypt the plaintext */
            return pbeCipher.doFinal(plaintext);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

        try {
            /* Create PBE Cipher */
            Cipher cipher = getCipher(Cipher.DECRYPT_MODE, password);
            /* get the plaintext */
            return cipher.doFinal(cyphertext);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

        // Our cleartext
        byte[] cleartext = plaintext.getBytes();

        // Encrypt the cleartext
        return pbeCipher.doFinal(cleartext);
    }


    private static String getDecrypted(byte[] cyphertext)
        throws Exception {
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

        // Initialize PBE Cipher with key and parameters
        pbeCipher.init(Cipher.DECRYPT_MODE, pbeKey, pbeParamSpec);

        // Encrypt the cleartext
        return new String(pbeCipher.doFinal(cyphertext));
    }
}
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

    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;
  }

  public static void main(String args[]) throws Exception {
    String key = "ABCDEFGH";
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

    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;
  }

  private byte desKey[];
}
View Full Code Here

Examples of javax.crypto.Cipher.doFinal()

      BigInteger n = new BigInteger(secret, 16);
      byte[] encoding = n.toByteArray();
     
      Cipher cipher = Cipher.getInstance("Blowfish");
      cipher.init(Cipher.DECRYPT_MODE, key);
      byte[] decode = cipher.doFinal(encoding);
      return new String(decode);
   }

    private static String decodePBE(MBeanServerConnection server, String password, String jaasSecurityDomain) throws Exception
    {
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.