Package javax.crypto

Examples of javax.crypto.Cipher.doFinal()


      serverProperties.store(byteArrayOutStream, "CentraView Server Properties");

      Cipher cipher = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
      cipher.init(Cipher.ENCRYPT_MODE, blowfishKey, ivSpec);

      returnByteArray = cipher.doFinal(byteArrayOutStream.toByteArray());
    } catch (Exception exception) {
      logger.error("[encryptServerData] Exception thrown.", exception);
    }
    return returnByteArray;
  } //end of encryptServerData method
View Full Code Here


      RSAPublicKey publicKey = (RSAPublicKey)keyFactory.generatePublic(publicKeySpec);

      Cipher cipher = Cipher.getInstance("RSA");
      cipher.init(Cipher.ENCRYPT_MODE, publicKey);

      returnByteArray = cipher.doFinal(blowfishKey.getEncoded());
    } catch (Exception exception) {
      logger.error("[encryptBlowfishKey] Exception thrown.", exception);
    }
    return returnByteArray;
  } //end of encryptServerData method
View Full Code Here

    SecretKey cipherKey = factory.generateSecret(keySpec);
    // Decode the secret
    byte[] encoding = Base64Utils.fromb64(secret);
    Cipher cipher = Cipher.getInstance(this.pbealgo);
    cipher.init(Cipher.DECRYPT_MODE, cipherKey, cipherSpec);
    byte[] decode = cipher.doFinal(encoding);
    return new String(decode).toCharArray();
  }
}
View Full Code Here

    Cipher cipher = Cipher.getInstance(DES);
    // ���ܳ׳�ʼ��Cipher����
    cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
    // ���ڣ���ȡ���ݲ�����
    // ��ʽִ�м��ܲ���
    return cipher.doFinal(src);
  }
 
  /**
   * ����
   * @param src  ����Դ
View Full Code Here

    Cipher cipher = Cipher.getInstance(DES);
    // ���ܳ׳�ʼ��Cipher����
    cipher.init(Cipher.DECRYPT_MODE, securekey, sr);
    // ���ڣ���ȡ���ݲ�����
    // ��ʽִ�н��ܲ���
    return cipher.doFinal(src);
  }
    /**
     * �������
     * @param data
     * @return
 
View Full Code Here

    Cipher cipher = Cipher.getInstance(DES);
    // ���ܳ׳�ʼ��Cipher����
    cipher.init(Cipher.ENCRYPT_MODE, securekey, sr);
    // ���ڣ���ȡ���ݲ�����
    // ��ʽִ�м��ܲ���
    return cipher.doFinal(src);
  }
 
  /**
   * ����
   * @param src  ����Դ
View Full Code Here

    Cipher cipher = Cipher.getInstance(DES);
    // ���ܳ׳�ʼ��Cipher����
    cipher.init(Cipher.DECRYPT_MODE, securekey, sr);
    // ���ڣ���ȡ���ݲ�����
    // ��ʽִ�н��ܲ���
    return cipher.doFinal(src);
  }
    /**
     * ���ݽ���
     * @param data
     * @param key ��Կ
View Full Code Here

   
      Cipher cipher = Cipher.getInstance( PBE_ALG );
     
      cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
 
      byte[]  enc = cipher.doFinal( data );
     
      byte[]  res = new byte[salt.length + enc.length];
     
      System.arraycopy( salt, 0, res, 0, salt.length );
     
View Full Code Here

     
      cipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
 
      fail_is_pw_error = true;
     
      return( cipher.doFinal( data, 8, data.length-8 ));
     
    }catch( Throwable e ){
     
      if ( fail_is_pw_error ){
       
View Full Code Here

      try{
        Cipher  rsa_cipher = Cipher.getInstance( "RSA" );
       
        rsa_cipher.init( Cipher.ENCRYPT_MODE, public_key );
       
        encryped_session_key = rsa_cipher.doFinal( secret_bytes );
       
      }catch( Throwable e ){
       
          // fallback to the BC implementation for jdk1.4.2 as JCE RSA not available
       
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.