Home > Net >  Java AES in c # how to decrypt. Online means have tried, it is difficult to row.
Java AES in c # how to decrypt. Online means have tried, it is difficult to row.

Time:03-09

Java Hutool toolkit for the encryption

AES AES=SecureUtil. AES (key);
Byte [] encrypt=aes encrypt (content).
String encryptHex=aes. EncryptHex (encrypt);

C # support decryption:

CodePudding user response:

Try after specified encryption mode to the ECB

CodePudding user response:

Public static string AESDecrypst (byte [] key, byte [] STR, byte [] IV)
{
Try
{
Using (var rijndaelManaged=new rijndaelManaged ()
{
Key=Key,
IV=IV,
KeySize=256,
BlockSize=128,
Mode=CipherMode. CBC,//operation Mode
Padding=PaddingMode. None//filling way
})
{
//create a decryption device object
Using (var transform=rijndaelManaged. CreateDecryptor (key and IV))
{
Var encryptedBytes=transform. TransformFinalBlock (STR, 0, STR. Length);//encryption
Return BitConverter. ToString (encryptedBytes). Replace (" - ", "");//will be encrypted into a string of bytes circulation, so that the network transmission and storage,
}
}
}
The catch (Exception e)
{
Throw e;
}
}
Different decryption result is nothing more than IV, disclosure Mode, Padding filling way, change to be same as used for Java Settings, the results can be the same
  •  Tags:  
  • C#
  • Related