Java code for all API methods
public String encryptKRSCertificate(String encodedJsonObj, String encodedAESKey) throws Exception
{
byte[] decodedKey = Base64.decode(encodedAESKey;
SecretKey key = new SecretKeySpec(decodedKey, 0, decodedKey.length, "AES"); byte[] iv = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
IvParameterSpec ivspec = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(1, key, ivspec);
byte[] encrypted = cipher.doFinal(Base64.decode(orignalCertificate)); String encryptedKeystore = new String(Base64.encode(encrypted)); return encryptedKeystore;
}
.NET code for all API methods
public byte[] EncryptDataAES(byte[] toEncrypt, string encodedAESKey)
{
byte[] key = Convert.FromBase64String(encodedAESKey); IBufferedCipher cipher =
CipherUtilities.GetCipher("AES/CBC/PKCS5PADDING"); cipher.Init(true, new KeyParameter(key));
int outputSize = cipher.GetOutputSize(toEncrypt.Length); byte[] tempOP = new byte[outputSize];
int processLen = cipher.ProcessBytes(toEncrypt, 0, toEncrypt.Length, tempOP, 0);
int outputLen = cipher.DoFinal(tempOP, processLen); byte[] result = new byte[processLen + outputLen]; System.Array.Copy(tempOP, 0, result, 0, result.Length); return result;
}