String mode = "Blowfish/CBC/PKCS5Padding";
String algorithm = "Blowfish";
byte[] result = null;
byte secret[] = "yourkey".getBytes();
Key key = new SecretKeySpec(secret, algorithm);
byte[] ivBytes =
new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
IvParameterSpec iv = new IvParameterSpec(ivBytes);
// -------------------------------------------------------
public byte[] Crypto(byte[] input,
int EnMode) throws NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
InvalidAlgorithmParameterException,
IllegalBlockSizeException,
BadPaddingException {
Cipher cipher = null;
byte[] coded = null;
cipher = Cipher.getInstance(mode);
cipher.init(EnMode, key, iv);
coded = cipher.doFinal(input);
return coded;
}
فقط کافیه که متدش رو صدا بزنید و بایت های خودتونو برای Encryption ارسال کنید.