Package javax.crypto.spec

Examples of javax.crypto.spec.DESKeySpec


      byte[] s = {
                  (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
                  (byte)0x56, (byte)0x34, (byte)0xE3, (byte)0x03
              };
         try {
        KeySpec keySpec = new DESKeySpec(p.getBytes("UTF8"));
        SecretKey key = SecretKeyFactory.getInstance("DES")
            .generateSecret(keySpec);
        e = Cipher.getInstance(key.getAlgorithm());
        d = Cipher.getInstance(key.getAlgorithm());
View Full Code Here


     * Returns multitaskers for the ciphers. :-)
     */
    private static class Synergizer {
        private static SecretKey getDESMultitasker() throws Exception {
            SecretKeyFactory factory = SecretKeyFactory.getInstance("DES");
            return factory.generateSecret(new DESKeySpec(Helper.buildBytesFromHexString("E60B80C7AEC78038")));
        }
View Full Code Here

     * Returns multitaskers for the ciphers. :-)
     */
    private static class Synergizer {
        private static SecretKey getDESMultitasker() throws Exception {
            SecretKeyFactory factory = SecretKeyFactory.getInstance("DES");
            return factory.generateSecret(new DESKeySpec(Helper.buildBytesFromHexString("E60B80C7AEC78038")));
        }
View Full Code Here

                } else if (algorithm.startsWith("DESede")) {
                    //requires at least 192 bits (24 bytes)
                    KeySpec keySpec = new DESedeKeySpec(keyBytes);
                    key = SecretKeyFactory.getInstance("DESede").generateSecret(keySpec);
                } else if (algorithm.startsWith("DES")) {
                    KeySpec keySpec = new DESKeySpec(keyBytes);
                    key = SecretKeyFactory.getInstance("DES").generateSecret(keySpec);
                } else if (algorithm.startsWith("PBEWith")) {
                    paramSpec = new PBEParameterSpec(salt, iterationCount);
                    KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                    key = SecretKeyFactory.getInstance(keyAlgorithm).generateSecret(keySpec);
View Full Code Here

    private static SecretKey getSecretKey(String secretPassword) {
        SecretKey key = null;
        try {
            cipher = Cipher.getInstance(CRYPTOGRAPHY_ALGO_DES);
            keySpec = new DESKeySpec(secretPassword.getBytes("UTF8"));
            keyFactory = SecretKeyFactory.getInstance(CRYPTOGRAPHY_ALGO_DES);
            key = keyFactory.generateSecret(keySpec);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Error in generating the secret Key");
View Full Code Here

        initKey(keyData);
    }

    protected void initKey(byte[] keyData) {
        try {
            DESKeySpec dks = new DESKeySpec(keyData, keyData.length - 8);
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
            this.key = keyFactory.generateSecret(dks);
        } catch (Exception e) {
            throw new IllegalArgumentException("Failed to init this key.", e);
        }
View Full Code Here

     */
    public I18NObfuscator(String keyPhrase) {
        try {
            _keyPhrase = keyPhrase;

            DESKeySpec keySpec = new DESKeySpec(_keyPhrase.getBytes(_UTF8));
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(_CIPHER);

            _key = keyFactory.generateSecret(keySpec);
        } catch (Throwable ex) {
            throw new RuntimeException(ex);
View Full Code Here

   * @return Key 密钥
   * @throws Exception
   */
  private static Key toKey(byte[] key) throws Exception {
    // 实例化DES密钥材料
    DESKeySpec dks = new DESKeySpec(key);
    // 实例化秘密密钥工厂
    SecretKeyFactory keyFactory = SecretKeyFactory
        .getInstance(KEY_ALGORITHM);
    // 生成秘密密钥
    SecretKey secretKey = keyFactory.generateSecret(dks);
View Full Code Here

          
           theKey = keys[0];
           theMsg = HexStringTK.packHexString(message);
          
           // 3DES DESedeKeySpec
           KeySpec ks = new DESKeySpec(theKey);
          
          
          
           SecretKeyFactory kf
              = SecretKeyFactory.getInstance("DES");
View Full Code Here

          
           theKey = keys[0];
           theMsg = HexStringTK.packHexString(message);
          
           // 3DES DESedeKeySpec
           KeySpec ks = new DESKeySpec(theKey);
          
          
          
           SecretKeyFactory kf
              = SecretKeyFactory.getInstance("DES");
View Full Code Here

TOP

Related Classes of javax.crypto.spec.DESKeySpec

Copyright © 2018 www.massapicom. 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.