Esempio n. 1
0
        public string BHasherSHA256Test(string toHash)
        {
            BHasher hasher = new BHasherSHA256();

            byte[] byt = Encoding.ASCII.GetBytes(toHash);
            hasher.Add(byt, 0, byt.Length);
            BHash hash = hasher.Finish();

            System.Console.WriteLine("BHasherSHA256 hash output = " + hash.ToString());
            return(hash.ToString());
        }
Esempio n. 2
0
        // Create a region hash made of the hashes of all the SOGs in the region
        public static BHash CreateRegionHash(Scene pScene)
        {
            BHasher regionHasher = new BHasherSHA256();

            regionHasher.Add(pScene.RegionInfo.RegionID.GetBytes(), 0, 16);

            foreach (SceneObjectGroup sog in pScene.GetSceneObjectGroups().OrderBy(x => x.UUID))
            {
                regionHasher.Add(LodenRegion.CreateSOGHash(sog));
            }

            return(regionHasher.Finish());
        }
Esempio n. 3
0
        // Create a uniquifying hash for this SOG instance.
        // The hash includes the UUID, a hash of the prim paramters, and the position in the scene.
        public static BHash CreateSOGHash(SceneObjectGroup pSog)
        {
            BHasher sogHasher = new BHasherSHA256();

            sogHasher.Add(pSog.UUID.GetBytes(), 0, 16);
            foreach (SceneObjectPart sop in pSog.Parts.OrderBy(x => x.UUID))
            {
                sogHasher.Add(sop.UUID.GetBytes(), 0, 16);
                sogHasher.Add(sop.Shape.GetMeshKey(sop.Scale, (float)OMVR.DetailLevel.Highest));
                LodenRegion.AddPositionToHash(sogHasher, sop.AbsolutePosition, sop.RotationOffset);
            }
            ;
            return(sogHasher.Finish());
        }
Esempio n. 4
0
        public void BHasherParameterParts()
        {
            byte[] testBytes = new byte[100];
            Random rand      = new Random();

            rand.NextBytes(testBytes);
            BHasher hasher1 = new BHasherMdjb2();
            BHasher hasher2 = new BHasherMdjb2();

            TestHasher("Mdjb2", hasher1, hasher2, testBytes);
            hasher1 = new BHasherMD5();
            hasher2 = new BHasherMD5();
            TestHasher("MD5", hasher1, hasher2, testBytes);
            hasher1 = new BHasherSHA256();
            hasher2 = new BHasherSHA256();
            TestHasher("SHA256", hasher1, hasher2, testBytes);
        }