1- using System . Collections . Generic ;
2- using System . Security . Cryptography ;
3- using System . Text ;
1+ using MLAPI . NetworkingManagerComponents . Binary ;
2+ using System . Collections . Generic ;
43
54namespace MLAPI . Data
65{
@@ -14,15 +13,10 @@ internal static ulong GetMessageAttributeHash(string name)
1413 if ( messageAttributeHashes . ContainsKey ( name ) )
1514 return messageAttributeHashes [ name ] ;
1615
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 ;
2620 }
2721
2822 internal static string GetAttributeMethodName ( ulong hash )
@@ -38,14 +32,9 @@ internal static void RegisterMessageAttributeName(string name)
3832 if ( messageAttributeHashes . ContainsKey ( name ) )
3933 return ;
4034
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 ) ;
4938 }
5039 }
5140}
0 commit comments