@@ -107,12 +107,7 @@ public static byte[] Murmur128(this ReadOnlySpan<byte> value, uint seed)
107107 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
108108 public static byte [ ] Sha256 ( this byte [ ] value )
109109 {
110- #if ! NET5_0_OR_GREATER
111- using var sha256 = SHA256 . Create ( ) ;
112- return sha256 . ComputeHash ( value ) ;
113- #else
114110 return SHA256 . HashData ( value ) ;
115- #endif
116111 }
117112
118113 /// <summary>
@@ -123,12 +118,7 @@ public static byte[] Sha256(this byte[] value)
123118 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
124119 public static byte [ ] Sha512 ( this byte [ ] value )
125120 {
126- #if ! NET5_0_OR_GREATER
127- using var sha512 = SHA512 . Create ( ) ;
128- return sha512 . ComputeHash ( value ) ;
129- #else
130121 return SHA512 . HashData ( value ) ;
131- #endif
132122 }
133123
134124 /// <summary>
@@ -141,12 +131,7 @@ public static byte[] Sha512(this byte[] value)
141131 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
142132 public static byte [ ] Sha256 ( this byte [ ] value , int offset , int count )
143133 {
144- #if ! NET5_0_OR_GREATER
145- using var sha256 = SHA256 . Create ( ) ;
146- return sha256 . ComputeHash ( value , offset , count ) ;
147- #else
148134 return SHA256 . HashData ( value . AsSpan ( offset , count ) ) ;
149- #endif
150135 }
151136
152137 /// <summary>
@@ -159,12 +144,7 @@ public static byte[] Sha256(this byte[] value, int offset, int count)
159144 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
160145 public static byte [ ] Sha512 ( this byte [ ] value , int offset , int count )
161146 {
162- #if ! NET5_0_OR_GREATER
163- using var sha512 = SHA512 . Create ( ) ;
164- return sha512 . ComputeHash ( value , offset , count ) ;
165- #else
166147 return SHA512 . HashData ( value . AsSpan ( offset , count ) ) ;
167- #endif
168148 }
169149
170150 /// <summary>
@@ -176,12 +156,7 @@ public static byte[] Sha512(this byte[] value, int offset, int count)
176156 public static byte [ ] Sha256 ( this ReadOnlySpan < byte > value )
177157 {
178158 var buffer = new byte [ 32 ] ;
179- #if ! NET5_0_OR_GREATER
180- using var sha256 = SHA256 . Create ( ) ;
181- sha256 . TryComputeHash ( value , buffer , out _ ) ;
182- #else
183159 SHA256 . HashData ( value , buffer ) ;
184- #endif
185160 return buffer ;
186161 }
187162
@@ -194,12 +169,7 @@ public static byte[] Sha256(this ReadOnlySpan<byte> value)
194169 public static byte [ ] Sha512 ( this ReadOnlySpan < byte > value )
195170 {
196171 var buffer = new byte [ 64 ] ;
197- #if ! NET5_0_OR_GREATER
198- using var sha512 = SHA512 . Create ( ) ;
199- sha512 . TryComputeHash ( value , buffer , out _ ) ;
200- #else
201172 SHA512 . HashData ( value , buffer ) ;
202- #endif
203173 return buffer ;
204174 }
205175
0 commit comments