Skip to content

Commit

Permalink
Close #1760
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Jan 8, 2025
1 parent 02c5f3a commit 29d1f86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Neo/Cryptography/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ public static byte[] RIPEMD160(this byte[] value)
/// <returns>The computed hash code.</returns>
public static byte[] RIPEMD160(this ReadOnlySpan<byte> value)
{
byte[] source = value.ToArray();
return source.RIPEMD160();
using var ripemd160 = new RIPEMD160Managed();

var output = new Span<byte>(new byte[ripemd160.HashSize]);
if (!ripemd160.TryComputeHash(value, output, out _))
throw new Exception();

return output.ToArray();
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Neo/Cryptography/RIPEMD160Managed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;

namespace Neo.Cryptography
{
Expand Down

0 comments on commit 29d1f86

Please sign in to comment.