Can someone help with the java alternative for the following .net code?
i am not able to find a proper alternative for the classes and methods used here.

public static byte[] EncryptPolicy(string data, string key) { if (!string.IsNullOrEmpty(data)) { Rfc2898DeriveBytes keyGenerator = new Rfc2898DeriveBytes(key, 8); Rijndael aes = Rijndael.Create(); aes.IV = keyGenerator.GetBytes(aes.BlockSize / 8); aes.Key = keyGenerator.GetBytes(aes.KeySize / 8); byte[] encrypted = null; // encrypt the data byte[] rawData = Encoding.UTF8.GetBytes(data); using (MemoryStream memoryStream = new MemoryStream()) using (CryptoStream cryptoStream = new CryptoStream(memoryStream, aes.CreateEncryptor(), CryptoStreamMode.Write)) { memoryStream.Write(keyGenerator.Salt, 0, keyGenerator.Salt.Length); cryptoStream.Write(rawData, 0, rawData.Length); cryptoStream.Close(); encrypted = memoryStream.ToArray(); } return encrypted; } else { throw new ArgumentNullException("NoText"); } }Thanks in advance


Check Solution