public static string PublicKeyToAddress(byte[] publicKey, int networkPrefix) { KeccakDigest shaDigest = new KeccakDigest(256); byte[] bytesFirst = new byte[32]; shaDigest.BlockUpdate(publicKey, 0, 32); shaDigest.DoFinal(bytesFirst, 0); RipeMD160Digest digestRipeMd160 = new RipeMD160Digest(); byte[] bytesSecond = new byte[20]; digestRipeMd160.BlockUpdate(bytesFirst, 0, 32); digestRipeMd160.DoFinal(bytesSecond, 0); byte[] bytesThird = CryptoBytes.FromHexString( string.Concat(networkPrefix, CryptoBytes.ToHexStringLower(bytesSecond)) ); byte[] bytesFourth = new byte[32]; shaDigest.BlockUpdate(bytesThird, 0, 21); shaDigest.DoFinal(bytesFourth, 0); byte[] bytesFifth = new byte[4]; Array.Copy(bytesFourth, 0, bytesFifth, 0, 4); byte[] bytesSixth = new byte[25]; Array.Copy(bytesThird, 0, bytesSixth, 0, 21); Array.Copy(bytesFifth, 0, bytesSixth, 21, 4); return(Base32.Encode(bytesSixth).ToUpper()); }
public Address(Byte[] data, Byte version = PUBKEY) { SHA256 sha256 = SHA256.Create(); IDigest ripemd160 = new RipeMD160Digest(); switch (version) { case PUBKEY: byte[] pubKeySHA256Res = sha256.ComputeHash(data); ripemd160.BlockUpdate(pubKeySHA256Res, 0, pubKeySHA256Res.Length); byte[] pubKeyResult = new byte[ripemd160.GetDigestSize()]; ripemd160.DoFinal(pubKeyResult, 0); pubKeyHash = pubKeyResult; version = PUBKEYHASH; break; case SCRIPT: byte[] scriptSHA256Res = sha256.ComputeHash(data); ripemd160.BlockUpdate(scriptSHA256Res, 0, scriptSHA256Res.Length); byte[] scriptResult = new byte[ripemd160.GetDigestSize()]; ripemd160.DoFinal(scriptResult, 0); scriptHash = scriptResult; version = SCRIPTHASH; break; case PUBKEYHASH: pubKeyHash = data; break; case SCRIPTHASH: scriptHash = data; break; } this.type = version; }
public static void RIPEMD160(ReadOnlySpan <byte> data, Span <byte> hash) { var d = new RipeMD160Digest(); d.BlockUpdate(data); d.DoFinal(hash); }
public static byte[] RIPEMD160(byte[] data) { var digest = new RipeMD160Digest(); var result = new byte[digest.GetDigestSize()]; digest.BlockUpdate(data, 0, data.Length); digest.DoFinal(result, 0); return(result); }
/// <summary> /// Ripemd160 hash /// </summary> static public byte[] RipeMD160Hash(byte[] data) { RipeMD160Digest digest = new RipeMD160Digest(); digest.BlockUpdate(data, 0, data.Length); byte[] hash = new byte[digest.GetDigestSize()]; digest.DoFinal(hash, 0); return(hash); }
public static byte[] RIPEMD160(byte[] data, int count) { RipeMD160Digest ripemd = new RipeMD160Digest(); ripemd.BlockUpdate(data, 0, count); byte[] rv = new byte[20]; ripemd.DoFinal(rv, 0); return(rv); }
public static byte[] Hash160(byte[] bytes) { var digest = new RipeMD160Digest(); var output = new byte[digest.GetDigestSize()]; digest.BlockUpdate(bytes, 0, bytes.Length); digest.DoFinal(output, 0); return(output); }
public static byte[] ComputeRIPEMD160(byte[] data) { IDigest digest = new RipeMD160Digest(); byte[] buffer = new byte[digest.GetDigestSize()]; digest.BlockUpdate(data, 0, data.Length); digest.DoFinal(buffer, 0); return(buffer); }
public static byte[] RIPEMD160(byte[] data) { RipeMD160Digest ripemd160 = new RipeMD160Digest(); ripemd160.BlockUpdate(data, 0, data.Length); byte[] buffer = new byte[ripemd160.GetDigestSize()]; ripemd160.DoFinal(buffer, 0); return(buffer); }
public static ExtraHashAlgorithm CreateRipeMD160() { var ha = new RipeMD160Digest(); return(new ExtraHashAlgorithm( ha.AlgorithmName, ha.GetDigestSize(), ha.Reset, ha.BlockUpdate, ha.DoFinal )); }
public static byte[] RIPEMD160(byte[] data, int offset, int count) { var d = new RipeMD160Digest(); d.BlockUpdate(data.AsSpan(offset, count)); var rv = new byte[20]; d.DoFinal(rv.AsSpan <byte>()); return(rv); }
private static string CalcRipeMD160(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); RipeMD160Digest digest = new RipeMD160Digest(); digest.BlockUpdate(bytes, 0, bytes.Length); byte[] result = new byte[digest.GetDigestSize()]; digest.DoFinal(result, 0); return(BytesToHex(result)); }
public static byte[] Ripemd160(byte[] data) { var ripemd = new RipeMD160Digest(); ripemd.BlockUpdate(data, 0, data.Length); var output = new byte[20]; ripemd.DoFinal(output, 0); return(output); }
public override byte[] ComputeHash(byte[] input, int offset, int count) { var ripemd160 = new RipeMD160Digest(); var result = new byte[ripemd160.GetDigestSize()]; ripemd160.BlockUpdate(input, offset, count); ripemd160.DoFinal(result, 0); return(result); }
public static void RIPEMD160(ReadOnlySequence <byte> data, Span <byte> hash) { var d = new RipeMD160Digest(); foreach (var m in data) { d.BlockUpdate(m.Span); } d.DoFinal(hash); }
public static byte[] Hash160(byte[] message) { var digest = new RipeMD160Digest(); var output = new byte[digest.GetDigestSize()]; byte[] msg = message ?? new byte[0]; digest.BlockUpdate(msg, 0, msg.Length); digest.DoFinal(output, 0); return(output); }
public static byte[] RIPEMD160(byte[] data, int offset, int count) { var ripemd = new RipeMD160Digest(); ripemd.BlockUpdate(data, offset, count); var rv = new byte[20]; ripemd.DoFinal(rv, 0); return(rv); }
public static string CalcRIPEMD160(byte[] keyBytes) { var digest = new RipeMD160Digest(); digest.BlockUpdate(keyBytes, 0, keyBytes.Length); var result = new byte[digest.GetDigestSize()]; digest.DoFinal(result, 0); return(BytesToHex(result)); }
public static byte[] RipemdBytes(this IEnumerable <byte> message) { var hash = new RipeMD160Digest(); var messageArray = message as byte[] ?? message.ToArray(); hash.BlockUpdate(messageArray, 0, messageArray.Length); var result = new byte[20]; hash.DoFinal(result, 0); return(result); }
/// <summary> /// Calculates RIPEMD160(SHA256(input)). This is used in Address calculations. /// </summary> public static byte[] Sha256Hash160(this byte[] me) { byte[] sha256 = new SHA256Managed().ComputeHash(me); RipeMD160Digest digest = new RipeMD160Digest(); digest.BlockUpdate(sha256, 0, sha256.Length); byte[] result = new byte[20]; digest.DoFinal(result, 0); return(result); }
public static byte[] SHA256_RIPEMD160(byte[] input) { byte[] sha256 = new SHA256CryptoServiceProvider().ComputeHash(input); var digest = new RipeMD160Digest(); digest.BlockUpdate(sha256, 0, sha256.Length); var outArray = new byte[20]; digest.DoFinal(outArray, 0); return(outArray); }
/// <inheritdoc /> public override byte[] RIPEMD160(byte[] message, int offset, int count) { var hash = new RipeMD160Digest(); hash.BlockUpdate(message, offset, count); byte[] result = new byte[20]; hash.DoFinal(result, 0); return(result); }
public static byte[] Sha256Hash160(byte[] input) { var sha256 = new SHA256Managed().ComputeHash(input); var digest = new RipeMD160Digest(); digest.BlockUpdate(sha256, 0, sha256.Length); var @out = new byte[20]; digest.DoFinal(@out, 0); return(@out); }
/// <summary> /// Gets the RIPEMD160 digest for the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns>The digest string.</returns> public static string GetRipemd160(MemoryStream data) { var digest = new RipeMD160Digest(); digest.BlockUpdate(data.ToArray(), 0, (int)data.Length); var result = new byte[digest.GetDigestSize()]; digest.DoFinal(result, 0); return(BitConverter.ToString(result).Replace("-", "")); }
/// <summary> /// Gets the digest for the specified assembly. /// </summary> /// <param name="assembly">The assembly to calculate the digest from.</param> /// <returns>The digest string.</returns> public static string GetDigestFromAssembly(Assembly assembly) { var digest = new RipeMD160Digest(); var data = File.ReadAllBytes(assembly.Location); digest.BlockUpdate(data, 0, data.Length); var result = new byte[digest.GetDigestSize()]; digest.DoFinal(result, 0); return(BitConverter.ToString(result).Replace("-", "")); }
private void CopyIn(RipeMD160Digest t) { base.CopyIn(t); H0 = t.H0; H1 = t.H1; H2 = t.H2; H3 = t.H3; H4 = t.H4; Array.Copy(t.X, 0, X, 0, t.X.Length); xOff = t.xOff; }
public static string ComputeRipeMd160Hash(this string valueForHash) { var ripeMd160 = new RipeMD160Digest(); var hash = new byte[ripeMd160.GetDigestSize()]; foreach (var @byte in Encoding.UTF8.GetBytes(valueForHash)) { ripeMd160.Update(@byte); } ripeMd160.DoFinal(hash, 0); return(Hex.ToHexString(hash)); }
public string CalcRipeMD160(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); RipeMD160Digest digest = new RipeMD160Digest(); digest.BlockUpdate(bytes, 0, bytes.Length); byte[] result = new byte[digest.GetDigestSize()]; digest.DoFinal(result, 0); return(this.ConvertByteArrayToHexStringV1(result)); }
public static byte[] RIPEMD160(byte[] data, int offset, int count) { #if NONATIVEHASH || NETCORE || NETSTANDARD RipeMD160Digest ripemd = new RipeMD160Digest(); ripemd.BlockUpdate(data, offset, count); byte[] rv = new byte[20]; ripemd.DoFinal(rv, 0); return(rv); #else using (var ripm = new RIPEMD160Managed()) { return(ripm.ComputeHash(data, offset, count)); } #endif }
private static string CalculateRipeMD160Digest(string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); //RIPEMD160Managed hashstring = new RIPEMD160Managed(); //string tt = hashstring.ComputeHash(bytes) RipeMD160Digest digest = new RipeMD160Digest(); digest.BlockUpdate(bytes, 0, bytes.Length); byte[] result = new byte[digest.GetDigestSize()]; digest.DoFinal(result, 0); return(BytesToHex(result)); }
public static byte[] RIPEMD160(byte[] data, int offset, int count) { #if !DNXCORE50 using (var ripm = new RIPEMD160Managed()) { return ripm.ComputeHash(data, offset, count); } #else RipeMD160Digest ripemd = new RipeMD160Digest(); ripemd.BlockUpdate(data, offset, count); byte[] rv = new byte[20]; ripemd.DoFinal(rv, 0); return rv; #endif }