File tree Expand file tree Collapse file tree
src/JsonApiDotNetCore/Serialization/Response Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,13 +7,6 @@ namespace JsonApiDotNetCore.Serialization.Response;
77internal sealed class FingerprintGenerator : IFingerprintGenerator
88{
99 private static readonly byte [ ] Separator = "|"u8 . ToArray ( ) ;
10- private static readonly uint [ ] LookupTable = Enumerable . Range ( 0 , 256 ) . Select ( ToLookupEntry ) . ToArray ( ) ;
11-
12- private static uint ToLookupEntry ( int index )
13- {
14- string hex = index . ToString ( "X2" ) ;
15- return hex [ 0 ] + ( ( uint ) hex [ 1 ] << 16 ) ;
16- }
1710
1811 /// <inheritdoc />
1912 public string Generate ( IEnumerable < string > elements )
@@ -30,22 +23,6 @@ public string Generate(IEnumerable<string> elements)
3023 }
3124
3225 byte [ ] hash = hasher . GetHashAndReset ( ) ;
33- return ByteArrayToHex ( hash ) ;
34- }
35-
36- private static string ByteArrayToHex ( byte [ ] bytes )
37- {
38- // https://stackoverflow.com/questions/311165/how-do-you-convert-a-byte-array-to-a-hexadecimal-string-and-vice-versa
39-
40- char [ ] buffer = new char [ bytes . Length * 2 ] ;
41-
42- for ( int index = 0 ; index < bytes . Length ; index ++ )
43- {
44- uint value = LookupTable [ bytes [ index ] ] ;
45- buffer [ 2 * index ] = ( char ) value ;
46- buffer [ 2 * index + 1 ] = ( char ) ( value >> 16 ) ;
47- }
48-
49- return new string ( buffer ) ;
26+ return Convert . ToHexString ( hash ) ;
5027 }
5128}
You can’t perform that action at this time.
0 commit comments