[#1] Add presentation layer
Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
This commit is contained in:
parent
2800fff041
commit
bb6e187b61
22 changed files with 778 additions and 79 deletions
32
sdk/src/FrostFS.SDK.ModelsV2/ObjectId.cs
Normal file
32
sdk/src/FrostFS.SDK.ModelsV2/ObjectId.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.ModelsV2;
|
||||
|
||||
public class ObjectId
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
public ObjectId(string id)
|
||||
{
|
||||
Value = id;
|
||||
}
|
||||
|
||||
public static ObjectId FromHash(byte[] hash)
|
||||
{
|
||||
if (hash.Length != Helper.Sha256HashLength)
|
||||
{
|
||||
throw new FormatException("ObjectID must be a sha256 hash.");
|
||||
}
|
||||
return new ObjectId(Base58.Encode(hash));
|
||||
}
|
||||
|
||||
public byte[] ToHash()
|
||||
{
|
||||
return Base58.Decode(Value);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue