예제 #1
0
        public uint GetObjHash()
        {
            var gobj = "[Character]" + Model;

            // TODO: Account for any other units that have skins (requires skins to be implemented for those units)
            if (this is IChampion c)
            {
                var szSkin = "";
                if (c.Skin < 10)
                {
                    szSkin = "0" + c.Skin;
                }
                else
                {
                    szSkin = c.Skin.ToString();
                }
                gobj += szSkin;
            }

            return(HashFunctions.HashStringNorm(gobj));
        }
예제 #2
0
        private void ProcessData()
        {
            _archive.Files = new Dictionary <string, ArchiveFileInfo>();

            for (uint i = 0; i < _fileList.Length; i++)
            {
                var result = new ArchiveFileInfo();
                result.Path = ReadString(_pathListOffset + _pathList[_fileList[i].PathIndex].PathOffset, _pathList[_fileList[i].PathIndex].PathLength - 1);

                if (_fileList[i].PathHash != HashFunctions.LeagueHash(result.Path))
                {
                    Console.WriteLine("Invalid hash for a path: {0}", result.Path);
                    continue;
                }

                result.DataOffset = _fileList[i].DataOffset;
                result.DataLength = _fileList[i].DataLength;

                _archive.Files.Add(result.Path, result);
            }
        }
        public int TestHash(string section, string name)
        {
            Console.WriteLine("Testing: " + section + "*" + name);
            var hash = HashFunctions.GetInibinHash(section, name);

            if (_hashes.Contains(hash))
            {
                if (_draft.Hashes.ContainsKey(hash))
                {
                    if (_draft.Hashes[hash].Keys.ToList().Contains(section, StringComparer.OrdinalIgnoreCase))
                    {
                        if (_draft.Hashes[hash][section].Contains(name, StringComparer.OrdinalIgnoreCase))
                        {
                            return(3);
                        }
                    }
                    return(2);
                }
                return(1);
            }
            return(0);
        }
예제 #4
0
        void drawAxesBoxesAround(Vector3 position)
        {
            var dist    = 10;
            var vectors = new[] {
                new Vector3(dist, 0, 0), new Vector3(-dist, 0, 0), // x, pos and neg
                new Vector3(0, dist, 0), new Vector3(0, -dist, 0), // y, pos and neg
                new Vector3(0, 0, dist), new Vector3(0, 0, -dist), // z, pos and neg
            };
            var colors = new[] {
                new Vector3(255, 0, 0), new Vector3(255, 180, 180), // x, pos and neg
                new Vector3(0, 255, 0), new Vector3(180, 255, 180), // y, pos and neg
                new Vector3(0, 0, 255), new Vector3(180, 180, 255), // z, pos and neg
            };

            for (int i = 0; i < vectors.Length; i++)
            {
                var relativePos      = vectors[i];
                var color            = colors[i];
                var absolutePosition = position + new Vector3((float)relativePos[0], (float)relativePos[1], (float)relativePos[2]);
                HashFunctions.Draw3DBox(absolutePosition, new Vector3(0.3f, 0.3f, 0.3f),
                                        (byte)colors[i][0], (byte)colors[i][1], (byte)colors[i][2]);
            }
        }
예제 #5
0
파일: Hashes.cs 프로젝트: zsuxiong/libranet
        /// <summary>
        /// Computes a hash of a block of binary data.
        /// </summary>
        /// <param name="Function">Hash function.</param>
        /// <param name="Data">Binary data.</param>
        /// <returns>Hash value.</returns>
        public static byte[] ComputeHash(HashFunctions Function, Stream Data)
        {
            switch (Function)
            {
            case HashFunctions.MD5:
                return(ComputeMD5Hash(Data));

            case HashFunctions.SHA1:
                return(ComputeSHA1Hash(Data));

            case HashFunctions.SHA256:
                return(ComputeSHA256Hash(Data));

            case HashFunctions.SHA384:
                return(ComputeSHA384Hash(Data));

            case HashFunctions.SHA512:
                return(ComputeSHA512Hash(Data));

            default:
                throw new ArgumentException("Unrecognized hash function", nameof(Function));
            }
        }
예제 #6
0
파일: main.cs 프로젝트: ksa678491784/labs
    internal static int Main(string[] args)
    {
        calc_and_print_hash("test", HashFunctions.md5sum);
        calc_and_print_hash("test", (input, salt) => HashFunctions.md5sum(input, salt));

        calc_and_print_hash_func("test", HashFunctions.sha256sum);
        calc_and_print_hash_func("test", (input, salt) => HashFunctions.sha256sum(input, salt));

        Console.WriteLine();

        Type t = typeof(InspectMe);

        Console.WriteLine("Inspecting {0}..", t.FullName);
        Inspector.inspect(t);

        Console.WriteLine();
        Console.Write("Calling private InspectMe.Subtract(5, 3).. ");
        MethodInfo subtract_info = typeof(InspectMe).GetMethod("Subtract", BindingFlags.NonPublic | BindingFlags.Instance);

        Console.WriteLine(subtract_info.Invoke(new InspectMe(0, 0), new object[] { 5, 3 }));

        return(0);
    }
예제 #7
0
파일: AddBuff.cs 프로젝트: Kaap0/GameServer
        public AddBuff(AttackableUnit u, AttackableUnit source, int stacks, float time, BuffType buffType, string name, byte slot)
            : base(PacketCmd.PKT_S2C_AddBuff, u.NetId)
        {
            buffer.Write((byte)slot);                     //Slot
            buffer.Write((byte)buffType);                 //Type
            buffer.Write((byte)stacks);                   // stacks
            buffer.Write((byte)0x00);                     // Visible was (byte)0x00
            buffer.Write(HashFunctions.HashString(name)); //Buff id

            buffer.Write((int)0);                         // <-- Probably runningTime

            buffer.Write((float)0);                       // <- ProgressStartPercent

            buffer.Write((float)time);

            if (source != null)
            {
                buffer.Write(source.NetId); //source
            }
            else
            {
                buffer.Write((int)0);
            }
        }
예제 #8
0
        internal void wots_verify(HashFunctions hs, byte[] pk, byte[] sig, int sigOff, byte[] msg, byte[] masks)
        {
            int[] basew = new int[WOTS_L];
            int   i, c = 0;

            for (i = 0; i < WOTS_L1; i += 2)
            {
                basew[i]     = msg[i / 2] & 0xf;
                basew[i + 1] = (msg[i / 2] & 0xff) >> 4;
                c           += WOTS_W - 1 - basew[i];
                c           += WOTS_W - 1 - basew[i + 1];
            }

            for (; i < WOTS_L; i++)
            {
                basew[i] = c & 0xf;
                c      >>= 4;
            }

            for (i = 0; i < WOTS_L; i++)
            {
                gen_chain(hs, pk, i * HASH_BYTES, sig, sigOff + i * HASH_BYTES, masks, (basew[i] * HASH_BYTES), WOTS_W - 1 - basew[i]);
            }
        }
예제 #9
0
        public void drawPosition()
        {
            var pos = Game.Player.Character.Position;

            HashFunctions.Draw2DText($"X:{ pos.X:.##} Y:{pos.Y:.##} Z:{pos.Z:.##}", pos, Color.Red);
        }
예제 #10
0
        static void Main(string[] args)
        {
            //Console.WriteLine(Les2.CheckBrackets(""));
            //Console.WriteLine(Les3.Sum(123));
            //Console.WriteLine(Les3.Reverse("ASD"));

            //List<int> theList = new List<int>()
            //{
            //	0,1,2,3,4,5,6,7,8,9
            //};

            //Les3.PrintForward(theList, 3);
            //Console.WriteLine();
            //Les3.PrintBackwards(theList, 3);


            //Console.WriteLine();

            //// Arrange
            //while (true)
            //{
            //	Console.Write("enter power: ");
            //	string powerstr = Console.ReadLine();
            //	double power;
            //	long amount = 0;
            //	if (double.TryParse(powerstr, out power))
            //		amount = (long)(1 * Math.Pow(10, power));
            //	else
            //		Console.WriteLine("unsupported value");

            //	int[] unsortedArr = new int[amount];

            //	Random rnd = new Random();
            //	for (int i = 0; i < amount; i++)
            //	{
            //		unsortedArr[i] = rnd.Next((int)amount);
            //	}

            //	// Act
            //	Stopwatch sw = new Stopwatch();
            //	Console.WriteLine($"N = {amount} => {nameof(Sorting<int>.QuickSort)}({amount})");
            //	sw.Start();
            //	Sorting<int>.QuickSort(unsortedArr);
            //	sw.Stop();


            //	// Assert
            //	decimal ms = sw.ElapsedMilliseconds;
            //	Console.WriteLine($"T(N) = {ms}ms");
            //}


            // Generic Tree
            //TreeNode NodeA = new TreeNode("A");
            //TreeNode NodeB = new TreeNode("B");
            //TreeNode NodeC = new TreeNode("C");
            //TreeNode NodeD = new TreeNode("D");
            //TreeNode NodeE = new TreeNode("E");
            //TreeNode NodeF = new TreeNode("F");

            //NodeA.AddChild(NodeB);
            //NodeA.AddChild(NodeE);
            //NodeA.AddChild(NodeF);
            //NodeB.AddChild(NodeC);
            //NodeB.AddChild(NodeD);

            //TreeNode.PrintPreOrder(NodeA);
            //Console.ReadKey();

            // Binary Tree
            //BinaryNode<int> Node1 = new BinaryNode<int>(1, null, null);
            //BinaryNode<int> Node2 = new BinaryNode<int>(2, null, null);
            //BinaryNode<int> Node3 = new BinaryNode<int>(3, null, null);
            //BinaryNode<int> Node4 = new BinaryNode<int>(4, null, null);
            //BinaryNode<int> Node5 = new BinaryNode<int>(5, null, null);
            //BinaryNode<int> Node6 = new BinaryNode<int>(6, null, null);
            //BinaryNode<int> Node7 = new BinaryNode<int>(7, null, null);

            //Node1.Left = Node2;
            //Node1.Right = Node3;

            //Node2.Left = Node4;
            //Node2.Right = Node5;

            //Node3.Left = Node6;
            //Node3.Right = Node7;

            //BinaryTree<int> binaryTree = new BinaryTree<int>(Node1);

            //BinaryTreeIterator<int> treeIterator = new PostOrder<int>(binaryTree);
            //treeIterator.Print();

            //Console.WriteLine();

            //treeIterator = new InOrder<int>(binaryTree);
            //treeIterator.Print();

            //Console.WriteLine("Opdracht 4");
            //Console.WriteLine(binaryTree.ToString());


            //// FCNS Tree
            //FCNSTree<string>.FCNSNode fCNSNodeA = new FCNSTree<string>.FCNSNode("A");
            //FCNSTree<string>.FCNSNode fCNSNodeB = new FCNSTree<string>.FCNSNode("B");
            //FCNSTree<string>.FCNSNode fCNSNodeC = new FCNSTree<string>.FCNSNode("C");
            //FCNSTree<string>.FCNSNode fCNSNodeD = new FCNSTree<string>.FCNSNode("D");
            //FCNSTree<string>.FCNSNode fCNSNodeE = new FCNSTree<string>.FCNSNode("E");
            //FCNSTree<string>.FCNSNode fCNSNodeF = new FCNSTree<string>.FCNSNode("F");
            //FCNSTree<string>.FCNSNode fCNSNodeG = new FCNSTree<string>.FCNSNode("G");
            //FCNSTree<string>.FCNSNode fCNSNodeH = new FCNSTree<string>.FCNSNode("H");
            //FCNSTree<string>.FCNSNode fCNSNodeI = new FCNSTree<string>.FCNSNode("I");
            //FCNSTree<string>.FCNSNode fCNSNodeJ = new FCNSTree<string>.FCNSNode("J");
            //FCNSTree<string>.FCNSNode fCNSNodeK = new FCNSTree<string>.FCNSNode("K");

            //fCNSNodeA.FirstChild = fCNSNodeB;
            //fCNSNodeB.FirstChild = fCNSNodeF;
            //fCNSNodeF.NextSibling = fCNSNodeG;
            //fCNSNodeB.NextSibling = fCNSNodeC;
            //fCNSNodeC.NextSibling = fCNSNodeD;
            //fCNSNodeD.FirstChild = fCNSNodeH;
            //fCNSNodeD.NextSibling = fCNSNodeE;
            //fCNSNodeE.FirstChild = fCNSNodeI;
            //fCNSNodeI.NextSibling = fCNSNodeJ;
            //fCNSNodeJ.FirstChild = fCNSNodeK;


            //FCNSTree<string> fCNSTree = new FCNSTree<string>(fCNSNodeA);
            //Console.WriteLine(fCNSTree.Size());
            //fCNSTree.PrintPreOrder();

            //Console.ReadKey();

            //Implementations.BinarySearchTree.BinaryNode<int> Root = new Implementations.BinarySearchTree.BinaryNode<int>(6);
            //Implementations.BinarySearchTree.BinaryNode<int> Node1 = new Implementations.BinarySearchTree.BinaryNode<int>(6);
            //Implementations.BinarySearchTree.BinaryNode<int> Node2 = new Implementations.BinarySearchTree.BinaryNode<int>(6);
            //Implementations.BinarySearchTree.BinaryNode<int> Node3 = new Implementations.BinarySearchTree.BinaryNode<int>(6);
            //Implementations.BinarySearchTree.BinaryNode<int> Node4 = new Implementations.BinarySearchTree.BinaryNode<int>(6);

            //Root.Left = Node1;
            //Root.Right = Node2;

            //Node1.Left = Node3;
            //Node1.Right = Node4;


            //BinarySearchTree<int> bst = new BinarySearchTree<int>(Root);
            //Console.WriteLine(bst.InOrder());

            //Console.ReadKey();



            // ********************************** //
            //			   Graphs	              //
            // ********************************** //

            //Graph graph = new Graph();

            //graph.GetVertex("v0");
            //graph.GetVertex("v1");
            //graph.GetVertex("v2");
            //graph.GetVertex("v3");
            //graph.GetVertex("v4");
            //graph.GetVertex("v5");
            //graph.GetVertex("v6");

            //graph.AddEdge("v0", "v1", 2);
            //graph.AddEdge("v0", "v3", 1);

            //graph.AddEdge("v1", "v3", 3);
            //graph.AddEdge("v1", "v4", 10);

            //graph.AddEdge("v2", "v0", 4);
            //graph.AddEdge("v2", "v5", 5);

            //graph.AddEdge("v3", "v2", 2);
            //graph.AddEdge("v3", "v5", 8);
            //graph.AddEdge("v3", "v6", 4);
            //graph.AddEdge("v3", "v4", 2);

            //graph.AddEdge("v4", "v6", 6);

            //graph.AddEdge("v6", "v5", 1);

            //graph.Dijkstra("v0");
            //graph.PrintPath("v5");

            //Console.ReadKey();

            // ********************************** //
            //			 PriorityQueue			  //
            // ********************************** //
            //int size = 50;

            //ICollection<int> vals = new List<int>() { 14, 6, 5, 8, 1, 3, 12, 9, 7, 13, 2 };
            //PriorityQueue<int> q = new PriorityQueue<int>(vals);

            //Console.WriteLine(q.CheckValidity());
            //Console.WriteLine("done");
            //Console.ReadKey();

            // ********************************** //
            //			 Hashing				  //
            // ********************************** //
            int i = HashFunctions.Hash("Junk", 11 - 1);

            Console.WriteLine(i);
            Console.ReadKey();
        }
예제 #11
0
 public byte[] SHA224_SingleHash_EmptyInput()
 {
     return(HashFunctions.SHA224(null));
 }
예제 #12
0
 public byte[][] SHA224_MultiHash_EmptyInput()
 {
     return(HashFunctions.SHA224Parallel(null, null, null, null));
 }
예제 #13
0
 public byte[] MD5_SingleHash_EmptyInput()
 {
     return(HashFunctions.MD5(null));
 }
예제 #14
0
 public byte[][] MD5_MultiHash_Avx2_EmptyInput()
 {
     return(HashFunctions.MD5Parallel(null, null, null, null, null, null, null, null));
 }
        public void MD5()
        {
            var hash = HashFunctions.MD5(null);

            Assert.Equal(MD5Empty, MakeHashString(hash));
        }
        public void SHA384()
        {
            var hash = HashFunctions.SHA384(null);

            Assert.Equal(SHA384Empty, MakeHashString(hash));
        }
예제 #17
0
 private static void SetTargetAsWaypoint(Vector2 target)
 {
     HashFunctions.SetNewWaypoint(target);
 }
예제 #18
0
 public bool RemoveHash(Func <T, int> targetHash)
 {
     return(HashFunctions.Remove(targetHash));
 }
예제 #19
0
 /// <summary>
 /// Create a new hashed PIN.
 /// </summary>
 /// <param name="Value">Hash value created by partner.</param>
 /// <param name="Function">Function that was used to generate the hash value.</param>
 public HashedPIN(Hash_Value Value,
                  HashFunctions Function)
 {
     this.Value    = Value;
     this.Function = Function;
 }
예제 #20
0
 /// <returns>spell's unique ID</returns>
 public int GetId()
 {
     return((int)HashFunctions.HashString(SpellName));
 }
예제 #21
0
        public ITlsKdf_v1_3 GetInstance(HashFunctions hashFunction)
        {
            var hf = ShaAttributes.GetHashFunctionFromEnum(hashFunction);

            return(new TlsKdfv13(_hkdfFactory.GetKdf(hf), _shaFactory.GetShaInstance(hf), hf.OutputLen));
        }
 public string GetWitnessTransactionID()
 {
     return(HashFunctions.ComputeDoubleSha256(Serialize()).Reverse().ToArray().ToBase16());
 }
 public string GetTransactionID()
 {
     byte[] bytesToHash = (Flag == 1) ? SerializeWithoutWitness() : Serialize();
     return(HashFunctions.ComputeDoubleSha256(bytesToHash).Reverse().ToArray().ToBase16());
 }
예제 #24
0
 public void WriteStringHash(string str)
 {
     Write(HashFunctions.HashString(str));
 }
예제 #25
0
파일: DBUtilsHelper.cs 프로젝트: mo5h/omeo
 public static int GetHashCodeInLowerCase(string str)
 {
     return(HashFunctions.HashiString32(str));
 }