RFC2898DeriveBytes implementation in Java

て烟熏妆下的殇ゞ 提交于 2019-12-04 22:45:48

i have somehow figured a way. it was working properly

I have requested the .net counterpart to pass the key and IV as strings. I encoded them to byte[] and used the below code

 String sKey ="fromdotnetpart";

 String sIv="fromdotnetiv";

    byte[] bKey = key.getBytes();
    byte[] iv = sIv.getBytes();
    SecretKeySpec skey = new SecretKeySpec(bKey, "AES");   
    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    AlgorithmParameterSpec param = new IvParameterSpec(iv);
    cipher.init(Cipher.DECRYPT_MODE, key,param);
    String decrypted = cipher.doFinal(encryptedString.getByte());

Hope this helps you. Please note that for higher strength AES encryption i.e AES-256,192 etc You need to download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!