byte[] encryptContentEncryptionKey(byte[] contentEncryptionKey,PublicKey publicKey) throws EncryptDataException {
  try {
    Cipher rsaCipher=Cipher.getInstance(RSA_ALGORITHM_MODE);
    rsaCipher.init(Cipher.ENCRYPT_MODE,publicKey);
    byte[] encryptedData=rsaCipher.doFinal(contentEncryptionKey);
    return encryptedData;
  }
 catch (  Exception e) {
    throw new EncryptDataException("Error while encrypting data ",e);
  }
}

byte [ ] encryptContentEncryptionKey ( byte [ ] contentEncryptionKey , PublicKey publicKey ) throws EncryptDataException { try { Cipher rsaCipher = Cipher . getInstance ( RSA_ALGORITHM_MODE ) ; rsaCipher . init ( Cipher . ENCRYPT_MODE , publicKey ) ; byte [ ] encryptedData = rsaCipher . doFinal ( contentEncryptionKey ) ; return encryptedData ; } catch ( Exception e ) { throw new EncryptDataException ( "Error while encrypting data " , e ) ; } }
encrypts a given contentencryptionkey with a public key using rsa
