Distribution_GL Initialization

This commit is contained in:
2026-10-20 13:07:07 +05:30
commit 3f16e0cb44
194 changed files with 35659 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
using System.Security.Cryptography;
using System.Text;
namespace General_Ledger_Service.Helpers
{
public static class EncryptionHelper
{
private static readonly byte[] Key = Convert.FromBase64String("6pY8vR2Nf+Xz9WkLm4TqQzB7vA9uS1nE5jR3hG6fM8o=");
public static string Encrypt(string plainText)
{
using Aes aes = Aes.Create();
aes.Key = Key;
aes.GenerateIV();
using var encryptor = aes.CreateEncryptor();
byte[] plainBytes = Encoding.UTF8.GetBytes(plainText);
byte[] cipherBytes = encryptor.TransformFinalBlock(plainBytes, 0, plainBytes.Length);
return Convert.ToBase64String(aes.IV.Concat(cipherBytes).ToArray());
}
public static string Decrypt(string combinedText)
{
byte[] combinedBytes = Convert.FromBase64String(combinedText);
using Aes aes = Aes.Create();
aes.Key = Key;
byte[] iv = [.. combinedBytes.Take(16)];
byte[] cipherBytes = [.. combinedBytes.Skip(16)];
using var decryptor = aes.CreateDecryptor(aes.Key, iv);
byte[] plainBytes = decryptor.TransformFinalBlock(cipherBytes, 0, cipherBytes.Length);
return Encoding.UTF8.GetString(plainBytes);
}
}
}