Home > Net >  On the issue of the AES decryption, for help
On the issue of the AES decryption, for help

Time:10-06

Inadvertently got a piece of code, could you tell me if the decryption
The login part
 User UserPsd!=new Encryption (). AESEncrypt (UserPsd, "www.baidu.com", "aoiohasoahod"); 

 
Public string AESEncrypt (string Data, string Key="www.baidu.com", string Vector="aoiohasoahod")
{
Byte [] bytes=Encoding. UTF8. GetBytes (Data);
Byte [] array=new byte [32].
Array. Copy (Encoding UTF8. GetBytes (Key. PadRight (Array. The Length), Array, Array. The Length).
Byte [] array2=new byte [16].
Array. Copy (Encoding UTF8. GetBytes (Vector) PadRight (array2. Length)), array2, array2. Length);
Byte [] inArray=null;
Rijndael Rijndael=Rijndael. The Create ();
Using (MemoryStream MemoryStream=new MemoryStream ())
{
Using (CryptoStream CryptoStream=new CryptoStream (memoryStream, rijndael CreateEncryptor (array, array2), CryptoStreamMode. Write))
{
CryptoStream. Write (0 bytes, bytes. The Length).
CryptoStream. FlushFinalBlock ();
InArray=memoryStream. ToArray ();
}
}
Return the Convert. ToBase64String (inArray);


Code is such, can you tell me this can decrypt it, or should I use online decryption platform decryption mode, can solve the hope bosses, leave a contact number is 200 integral vouchers sent it

CodePudding user response:

The main rijndael. CreateEncryptor with rijndael. CreateDecryptor,

Var base64=AES En crypt (" hello "); //base64 z3hs/xyA=='
Var plain=AES De> crypt (base64); //plain='hello'

 public string AESDecrypt (string Data, string Key="www.baidu.com", string Vector="aoiohasoahod") 
{
Byte [] bytes=the Convert. FromBase64String (Data);
Byte [] array=new byte [32].
Array. Copy (Encoding UTF8. GetBytes (Key. PadRight (Array. The Length), Array, Array. The Length).
Byte [] array2=new byte [16].
Array. Copy (Encoding UTF8. GetBytes (Vector) PadRight (array2. Length)), array2, array2. Length);

Rijndael Rijndael=Rijndael. The Create ();
Using (MemoryStream MemoryStream=new MemoryStream (bytes))
{
Using (CryptoStream CryptoStream=new CryptoStream (memoryStream, rijndael CreateDecryptor (array, array2), CryptoStreamMode. Read))
Using (var reader=new StreamReader (cryptoStream, Encoding UTF8))
{
Return reader. ReadToEnd ();
}
}
}

CodePudding user response:

Online decryption can use the
AES256
CBC with PKCS7
KEY and IV is a function of two parameters, pay attention to the KEY length is 32, IV is 16, the length of the length is not enough to fill the blank space at the back

CodePudding user response:

Public string AESDecrypt (string Data, string Key="www.baidu.com", string Vector="aoiohasoahod")
{
Byte [] bytes=the Convert. FromBase64String (Data);
Byte [] array=new byte [32].
Array. Copy (Encoding UTF8. GetBytes (Key. PadRight (Array. The Length), Array, Array. The Length).
Byte [] array2=new byte [16].
Array. Copy (Encoding UTF8. GetBytes (Vector) PadRight (array2. Length)), array2, array2. Length);

Rijndael Rijndael=Rijndael. The Create ();
Using (MemoryStream MemoryStream=new MemoryStream (bytes))
{
Using (CryptoStream CryptoStream=new CryptoStream (memoryStream, rijndael CreateDecryptor (array, array2), CryptoStreamMode. Read))
Using (var reader=new StreamReader (cryptoStream, Encoding UTF8))
{
Return reader. ReadToEnd ();
}
}
}

CodePudding user response:

refer to the second floor stherix response:
online decryption can use the
AES256
CBC with PKCS7
KEY and IV is a function of two parameters, pay attention to the KEY length is 32, IV is 16, the length of the length is not enough to fill the blank space at the back
for the first time Posting here, please leave QQ

CodePudding user response:

The 3 des encryption is the key and the vector must be initialized, that is, with zero again after filling to copy an Array (Array. Copy)
  •  Tags:  
  • C#
  • Related