{
String STR.
Byte [] buffer=the Convert. FromBase64String (input).
Byte [] buffer2.=Encoding UTF8. GetBytes (salt);
Using (AesManaged managed=new AesManaged ())
{
Rfc2898DeriveBytes bytes=new Rfc2898DeriveBytes (password, buffer2);
Managed. BlockSize=managed. LegalBlockSizes [0]. MaxSize;
Managed. The KeySize=managed. LegalKeySizes [0]. MaxSize;
Managed. The Key=bytes. GetBytes (managed. KeySize/8);
Managed. IV=bytes. GetBytes (managed. BlockSize/8);
Using (ICryptoTransform transform=managed. CreateDecryptor ())
{
MemoryStream stream=new MemoryStream ();
Using (CryptoStream stream2=new CryptoStream (stream, the transform, CryptoStreamMode. Write))
{
Stream2. Write (buffer, 0, buffer Length);
}
Byte [] buffer3=stream. ToArray ();
STR=Encoding. UTF8. Get string (buffer3, 0, buffer3. Length);
}
}
return str;
}
CodePudding user response:
The code above is a c # function, I want to use this code in c + + to encrypt, but copied directly to the c + + is certainly not, o master change