1
- using System . Collections . Generic ;
2
- using System . Security . Cryptography ;
3
- using System . Text ;
1
+ using MLAPI . NetworkingManagerComponents . Binary ;
2
+ using System . Collections . Generic ;
4
3
5
4
namespace MLAPI . Data
6
5
{
@@ -14,15 +13,10 @@ internal static ulong GetMessageAttributeHash(string name)
14
13
if ( messageAttributeHashes . ContainsKey ( name ) )
15
14
return messageAttributeHashes [ name ] ;
16
15
17
- using ( SHA256Managed sha = new SHA256Managed ( ) )
18
- {
19
- byte [ ] hash = sha . ComputeHash ( Encoding . UTF8 . GetBytes ( name ) ) ;
20
- ulong value = hash [ 0 ] | ( ( ulong ) hash [ 1 ] << 8 ) | ( ( ulong ) hash [ 2 ] << 16 ) | ( ( ulong ) hash [ 3 ] << 24 ) | ( ( ulong ) hash [ 4 ] << 32 ) | ( ( ulong ) hash [ 5 ] << 40 ) | ( ( ulong ) hash [ 6 ] << 48 ) | ( ( ulong ) hash [ 7 ] << 56 ) ;
21
- //ulong value = hash[0] | ((uint)hash[1] << 8) | ((uint)hash[2] << 16) | ((uint)hash[3] << 24);
22
- messageAttributeHashes . Add ( name , value ) ;
23
- messageAttributeNames . Add ( value , name ) ;
24
- return value ;
25
- }
16
+ ulong value = PrimitiveHasher . GetULongHash ( name ) ;
17
+ messageAttributeHashes . Add ( name , value ) ;
18
+ messageAttributeNames . Add ( value , name ) ;
19
+ return value ;
26
20
}
27
21
28
22
internal static string GetAttributeMethodName ( ulong hash )
@@ -38,14 +32,9 @@ internal static void RegisterMessageAttributeName(string name)
38
32
if ( messageAttributeHashes . ContainsKey ( name ) )
39
33
return ;
40
34
41
- using ( SHA256Managed sha = new SHA256Managed ( ) )
42
- {
43
- byte [ ] hash = sha . ComputeHash ( Encoding . UTF8 . GetBytes ( name ) ) ;
44
- ulong value = hash [ 0 ] | ( ( ulong ) hash [ 1 ] << 8 ) | ( ( ulong ) hash [ 2 ] << 16 ) | ( ( ulong ) hash [ 3 ] << 24 ) | ( ( ulong ) hash [ 4 ] << 32 ) | ( ( ulong ) hash [ 5 ] << 40 ) | ( ( ulong ) hash [ 6 ] << 48 ) | ( ( ulong ) hash [ 7 ] << 56 ) ;
45
- //ulong value = hash[0] | ((uint)hash[1] << 8) | ((uint)hash[2] << 16) | ((uint)hash[3] << 24);
46
- messageAttributeHashes . Add ( name , value ) ;
47
- messageAttributeNames . Add ( value , name ) ;
48
- }
35
+ ulong value = PrimitiveHasher . GetULongHash ( name ) ;
36
+ messageAttributeHashes . Add ( name , value ) ;
37
+ messageAttributeNames . Add ( value , name ) ;
49
38
}
50
39
}
51
40
}
0 commit comments