feat: non-generic FNV1a hasher added
This commit is contained in:
		
							
								
								
									
										21
									
								
								Engine.Systems/Network/Hasher.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Engine.Systems/Network/Hasher.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
namespace Engine.Systems.Network;
 | 
			
		||||
 | 
			
		||||
public static class Hasher
 | 
			
		||||
{
 | 
			
		||||
    public static long FNV1a(string name)
 | 
			
		||||
    {
 | 
			
		||||
        const long fnvPrime = 1099511628211;
 | 
			
		||||
        long result = 1469598103934665603;
 | 
			
		||||
 | 
			
		||||
        unchecked
 | 
			
		||||
        {
 | 
			
		||||
            foreach (char c in name)
 | 
			
		||||
            {
 | 
			
		||||
                result ^= c;
 | 
			
		||||
                result *= fnvPrime;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user