frostfs-sdk-csharp/src/FrostFS.SDK.Client/Models/Object/FrostFsObjectId.cs
Pavel Gross 749000a090
All checks were successful
DCO / DCO (pull_request) Successful in 33s
lint-build / dotnet8.0 (pull_request) Successful in 1m4s
lint-build / dotnet8.0 (push) Successful in 49s
[#28] Client: Apply code optimizations
Signed-off-by: Pavel Gross <p.gross@yadro.com>
2024-11-18 17:00:19 +03:00

28 lines
No EOL
575 B
C#

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