From e010f93b07492517bbfd67083e6cc4783964f33d Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 21 Jan 2023 17:04:00 +0300 Subject: [PATCH] 20230121 --- anbs_cp/Classes/Encrypt/EncriptKey.cs | 20 +++----------------- anbs_cp/anbs_cp.csproj | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/anbs_cp/Classes/Encrypt/EncriptKey.cs b/anbs_cp/Classes/Encrypt/EncriptKey.cs index 92b0cda..134c69f 100644 --- a/anbs_cp/Classes/Encrypt/EncriptKey.cs +++ b/anbs_cp/Classes/Encrypt/EncriptKey.cs @@ -7,7 +7,7 @@ namespace anbs_cp.Classes.Encrypt; /// /// Ключ шифровки / расшифровки /// -public class EncryptKey: IEncryptKey +public sealed class EncryptKey: IEncryptKey { /// /// Конструктор по умолчанию @@ -18,8 +18,8 @@ public class EncryptKey: IEncryptKey /// /// Конструктор, принимающий строку и преобразующий в нужный формат /// - /// Ключ в формате - public EncryptKey (string key) => Key = Encoding.ASCII.GetBytes(key); + /// Ключ в формате и в кодировке utf8 + public EncryptKey (string utf8Key) => Key = Encoding.UTF8.GetBytes(utf8Key); /// /// Ключ @@ -31,18 +31,4 @@ public class EncryptKey: IEncryptKey /// /// public static EncryptKey GetDefault () => new(Enumerable.Range(0, 32).Select(static x => (byte)x).ToArray()); - - /// - /// Получение класса ключа - /// - /// Ключ в формате массива - /// - public static EncryptKey GetKey (byte[]? key) => key != null ? new(key) : GetDefault(); - - /// - /// Получение класса ключа - /// - /// Ключ в формате массива - /// - public static EncryptKey GetKey (string key) => !string.IsNullOrWhiteSpace(key) ? new(key) : GetDefault(); } \ No newline at end of file diff --git a/anbs_cp/anbs_cp.csproj b/anbs_cp/anbs_cp.csproj index 59766de..ae60b44 100644 --- a/anbs_cp/anbs_cp.csproj +++ b/anbs_cp/anbs_cp.csproj @@ -2,7 +2,7 @@ net7.0 - 2023.120.0 + 2023.121.0 Alexander Babaev ANB Software Components Pack Library of some useful functions in C# language.