frostfs-sdk-csharp/src/FrostFS.SDK.ModelsV2/ContainerId.cs
Ivan Pchelintsev b307c2c899 [#1] Add object Get operation + code quality
Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
2024-05-22 14:29:20 +03:00

32 lines
No EOL
630 B
C#

using FrostFS.SDK.Cryptography;
namespace FrostFS.SDK.ModelsV2;
public class ContainerId
{
public string Value { get; set; }
public ContainerId(string id)
{
Value = id;
}
public static ContainerId FromHash(byte[] hash)
{
if (hash.Length != Constants.Sha256HashLength)
{
throw new FormatException("ContainerID must be a sha256 hash.");
}
return new ContainerId(Base58.Encode(hash));
}
public byte[] ToHash()
{
return Base58.Decode(Value);
}
public override string ToString()
{
return Value;
}
}