public byte [ ] encrypt ( PrivateKey privateKey , byte [ ] encryptedSecretKey , String data ) throws InvalidKeyException { byte [ ] encryptedData = null ; try { byte [ ] chave = privateKey . getEncoded ( ) ; // Decrypt secret symmetric key with private key Cipher rsacf = Cipher . getInstance ( "RSA" ) ; rsacf . init ( Cipher . DECRYPT_MODE , privateKey ) ; byte [ ] secretKey = rsacf . doFinal ( encryptedSecretKey ) ; encryptedData = encrypt ( secretKey , data ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Exception encrypting data" , e ) ; } return encryptedData ; }
Encrypt data using an key encrypted with a private key .