You are not logged in.
Pages: 1
Hello,
Can anyone help me with mORMot(v1 or V2 whatever ) decrypt string encrypted which such C# code?
public string Encrypt(string data, string key)
{
if (string.IsNullOrWhiteSpace(data))
{
return string.Empty;
}
using var aes = Aes.Create();
aes.Key = Encoding.UTF8.GetBytes(key);
var iv = Convert.ToBase64String(aes.IV);
var transform = aes.CreateEncryptor(aes.Key, aes.IV);
using var memoryStream = new MemoryStream();
using var cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
using (var streamWriter = new StreamWriter(cryptoStream))
{
streamWriter.Write(data);
}
return iv + Convert.ToBase64String(memoryStream.ToArray());
}
Last edited by Greg0r (2022-12-08 16:37:49)
Offline
ps. I know it's perhapns not the safest AES implmentation but it's more than enough for my purposes.
Offline
Hi, you can take a look there for example (v1, it's easy to port on v2), and in the source of `mormot.crypt.core` for more details (read the comments).
You can also find more recents details on a good blog post .
Online
Pages: 1