我需要Android格式的Rijndeal加密代码。现在我在java中有Rijndeal加密代码,但我无法使用相同的android代码集。请参考以下java代码并告诉我您的建议:
public static String Encrypt(String plainText, String passPhrase, int
saltValue, String hashAlgorithm, int passwordIterations, String
initVector, int keySize)
{
byte[] initVectorBytes = null;
initVectorBytes = Encoding.ASCII.GetBytes(initVector);
byte[] saltValueBytes = null;
saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
byte[] plainTextBytes = null;
plainTextBytes = Encoding.UTF8.GetBytes(plainText);
PasswordDeriveBytes password = null;
password = new PasswordDeriveBytes(passPhrase, saltValueBytes,
hashAlgorithm, passwordIterations);
byte[] keyBytes = null;
keyBytes = password.GetBytes(keySize / 8.0);
RijndaelManaged symmetricKey = null;
symmetricKey = new RijndaelManaged();
symmetricKey.Mode = Cipher.CBC;
ICryptoTransform encryptor = null;
encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes);
MemoryStream memoryStream = null;
memoryStream = new MemoryStream();
CryptoStream cryptoStream = null;
cryptoStream = new CryptoStream(memoryStream, encryptor,
CryptoStreamMode.Write);
// Start encrypting.
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.length);
// Finish encrypting.
cryptoStream.FlushFinalBlock();
// Convert our encrypted data from a memory stream into a byte array.
byte[] cipherTextBytes = null;
cipherTextBytes = memoryStream.ToArray();
// Close both streams.
memoryStream.Close();
cryptoStream.Close();
// Convert encrypted data into a base64-encoded string.
String cipherText = null;
cipherText = Convert.ToBase64String(cipherTextBytes);
// Return encrypted string.
return cipherText;
}
是否有人可以将以上代码转换为Android加密表单?