20230121
This commit is contained in:
parent
c89a6b2a71
commit
e010f93b07
@ -7,7 +7,7 @@ namespace anbs_cp.Classes.Encrypt;
|
||||
/// <summary>
|
||||
/// Ключ шифровки / расшифровки
|
||||
/// </summary>
|
||||
public class EncryptKey: IEncryptKey
|
||||
public sealed class EncryptKey: IEncryptKey
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор по умолчанию
|
||||
@ -18,8 +18,8 @@ public class EncryptKey: IEncryptKey
|
||||
/// <summary>
|
||||
/// Конструктор, принимающий строку и преобразующий в нужный формат
|
||||
/// </summary>
|
||||
/// <param name="key">Ключ в формате <see cref="string"/></param>
|
||||
public EncryptKey (string key) => Key = Encoding.ASCII.GetBytes(key);
|
||||
/// <param name="utf8Key">Ключ в формате <see cref="string"/> и в кодировке utf8</param>
|
||||
public EncryptKey (string utf8Key) => Key = Encoding.UTF8.GetBytes(utf8Key);
|
||||
|
||||
/// <summary>
|
||||
/// Ключ
|
||||
@ -31,18 +31,4 @@ public class EncryptKey: IEncryptKey
|
||||
/// </summary>
|
||||
/// <returns><see cref="EncryptKey"/></returns>
|
||||
public static EncryptKey GetDefault () => new(Enumerable.Range(0, 32).Select(static x => (byte)x).ToArray());
|
||||
|
||||
/// <summary>
|
||||
/// Получение класса ключа
|
||||
/// </summary>
|
||||
/// <param name="key">Ключ в формате массива <see cref="byte"/></param>
|
||||
/// <returns><see cref="EncryptKey"/></returns>
|
||||
public static EncryptKey GetKey (byte[]? key) => key != null ? new(key) : GetDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Получение класса ключа
|
||||
/// </summary>
|
||||
/// <param name="key">Ключ в формате массива <see cref="byte"/></param>
|
||||
/// <returns><see cref="EncryptKey"/></returns>
|
||||
public static EncryptKey GetKey (string key) => !string.IsNullOrWhiteSpace(key) ? new(key) : GetDefault();
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>2023.120.0</Version>
|
||||
<Version>2023.121.0</Version>
|
||||
<Authors>Alexander Babaev</Authors>
|
||||
<Product>ANB Software Components Pack</Product>
|
||||
<Description>Library of some useful functions in C# language.</Description>
|
||||
|
Loading…
x
Reference in New Issue
Block a user