X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=Novacoin%2FInterop.cs;h=55979d714e103777f76978973329f8dbacea8d80;hb=eb39142ad873e102405ceffb5ec837b510da9096;hp=0cb7e756e65c897869f1fa03463924bee3f14707;hpb=1ad33d77c24d57f7ac25e0d6cf5f430464cdb058;p=NovacoinLibrary.git diff --git a/Novacoin/Interop.cs b/Novacoin/Interop.cs index 0cb7e75..55979d7 100644 --- a/Novacoin/Interop.cs +++ b/Novacoin/Interop.cs @@ -82,6 +82,20 @@ namespace Novacoin return bytes; } + public static byte[] TrimArray(byte[] bytes) + { + int trimStart = bytes.Length - 1; + while (trimStart >= 0 && bytes[trimStart] == 0) + { + trimStart--; + } + + byte[] result = new byte[trimStart + 1]; + Array.Copy(bytes, 0, result, 0, trimStart + 1); + + return result; + } + public static string ToHex(byte[] bytes) { var sb = new StringBuilder();