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