public static Hash ConcatAndCompute(Hash hash1, Hash hash2, Hash hash3) { var bytes = ByteArrayHelper.ConcatArrays( ByteArrayHelper.ConcatArrays(hash1.ToByteArray(), hash2.ToByteArray()), hash3.ToByteArray()); return(ComputeFrom(bytes)); }
private static byte[] _AddCheckSum(byte[] data) { var checkSum = _GetCheckSum(data); var dataWithCheckSum = ByteArrayHelper.ConcatArrays(data, checkSum); return(dataWithCheckSum); }
//Returns null if the checksum is invalid private static byte[] _VerifyAndRemoveCheckSum(byte[] data) { var result = ByteArrayHelper.SubArray(data, 0, data.Length - CheckSumSize); var givenCheckSum = ByteArrayHelper.SubArray(data, data.Length - CheckSumSize); var correctCheckSum = _GetCheckSum(result); return(givenCheckSum.SequenceEqual(correctCheckSum) ? result : null); }
public static ByteString ToByteString(this string hexString) { return(ByteString.CopyFrom(ByteArrayHelper.HexStringToByteArray(hexString))); }
public static Hash ConcatAndCompute(Hash hash1, Hash hash2) { var bytes = ByteArrayHelper.ConcatArrays(hash1.ToByteArray(), hash2.ToByteArray()); return(Hash.FromRawBytes(bytes)); }
/// <summary> /// Loads the content value represented in hex string. /// </summary> /// <param name="hex"></param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public static Hash HexStringToHash(string hex) { var bytes = ByteArrayHelper.HexStringToByteArray(hex); return(Hash.FromByteArray(bytes)); }