[#1] Define SDK structure
TODO: Вынести маппинг модель -> grpc в отдельный слой Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
This commit is contained in:
parent
905f683bf1
commit
2800fff041
57 changed files with 5760 additions and 0 deletions
30
sdk/src/FrostFS.SDK.Cryptography/Tz/Helper.cs
Normal file
30
sdk/src/FrostFS.SDK.Cryptography/Tz/Helper.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Security.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.Cryptography.Tz
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
public static ulong NextUlong(this RandomNumberGenerator rng)
|
||||
{
|
||||
var buff = new byte[8];
|
||||
rng.GetBytes(buff);
|
||||
return BitConverter.ToUInt64(buff, 0);
|
||||
}
|
||||
|
||||
public static int GetLeadingZeros(ulong value)
|
||||
{
|
||||
var i = 64;
|
||||
while (value != 0)
|
||||
{
|
||||
value >>= 1;
|
||||
i--;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int GetNonZeroLength(this ulong value)
|
||||
{
|
||||
return 64 - GetLeadingZeros(value);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue