public byte[] encryptDataWithPrivateKey(byte[] buffer,int length){
  try {
    Cipher cipher=Cipher.getInstance(TTT_ENCRYPTION_ALGORITHM);
    cipher.init(Cipher.ENCRYPT_MODE,privateKey);
    byte[] cipherData=cipher.doFinal(buffer,0,length);
    return cipherData;
  }
 catch (  GeneralSecurityException e) {
    throw new IllegalStateException(e);
  }
}

public byte [ ] encryptDataWithPrivateKey ( byte [ ] buffer , int length ) { try { Cipher cipher = Cipher . getInstance ( TTT_ENCRYPTION_ALGORITHM ) ; cipher . init ( Cipher . ENCRYPT_MODE , privateKey ) ; byte [ ] cipherData = cipher . doFinal ( buffer , 0 , length ) ; return cipherData ; } catch ( GeneralSecurityException e ) { throw new IllegalStateException ( e ) ; } }
uses private key directly to encrypt the data . note that this is a slow method and not meant for high performance . see crypt . encryptdata ( ) for an alternative
