Encrypt in java and Decrypt in C# For AES 256 bit

前端 未结 4 1085
无人及你
无人及你 2020-12-03 01:44

1.I have java function which encrypt xml file and return encrypted String.

/// Java Class 
import java.security.Key;
import javax.crypto.Cipher;
import javax         


        
4条回答
  •  被撕碎了的回忆
    2020-12-03 02:38

    I believe the blockSize should be 128 and the keysize be 256. The keyStr should be 32 characters long and the IVstr should be 16 characters long. This may help as it describes why 128 bits have to be used for block size and what the key sizes can be. csrc.nist.gov/publications/fips/fips197/fips-197.pdf

    You have this in the decrypt method.

        aesEncryption.Padding = PaddingMode.None; 
    

    I believe you need to put that in the encrypt method also.

    Also why not use this method for the key and IV.

        aes.Key = ASCIIEncoding.ASCII.GetBytes(keyStr); 
        aes.IV = ASCIIEncoding.ASCII.GetBytes(ivStr);
    

提交回复
热议问题