New Text Document
New Text Document
Engines;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Iscore.Application.Common.Serivce
{
public class AesGcm256Service
{
private static readonly SecureRandom Random = new();
cipher.Init(true, parameters);
cipher.Init(false, parameters);
byte[] plainBytes = new
byte[cipher.GetOutputSize(encryptedBytes.Length)];
int retLen = cipher.ProcessBytes(encryptedBytes, 0,
encryptedBytes.Length, plainBytes, 0);
cipher.DoFinal(plainBytes, retLen);
return Encoding.UTF8.GetString(plainBytes).TrimEnd("\r\n\
0".ToCharArray());
}
catch (Exception)
{
return string.Empty;
}
}
return buffer;
}
}
}