Пример #1
0
        public void UpdateFileHash(string fileName, byte[] fileBytes)
        {
            DictionaryNode filesNode = PListHelper.GetDictionaryValueFromPList(RootNode, "files");

            byte[] hash = new SHA1Managed().ComputeHash(fileBytes);
            if (filesNode.ContainsKey(fileName))
            {
                filesNode[fileName] = new DataNode(hash);
            }

            DictionaryNode files2Node = PListHelper.GetDictionaryValueFromPList(RootNode, "files2");

            if (files2Node != null && files2Node.ContainsKey(fileName))
            {
                files2Node[fileName] = new DataNode(hash);
            }
        }
Пример #2
0
        public void UpdateFileHash(string fileName, byte[] fileBytes)
        {
            DictionaryNode filesNode = PListHelper.GetDictionaryValueFromPList(RootNode, "files");

            byte[] sha1Hash   = new SHA1Managed().ComputeHash(fileBytes);
            byte[] sha256Hash = new SHA256Managed().ComputeHash(fileBytes);
            if (filesNode.ContainsKey(fileName))
            {
                filesNode[fileName] = new DataNode(sha1Hash);
            }

            DictionaryNode files2Node = PListHelper.GetDictionaryValueFromPList(RootNode, "files2");

            if (files2Node != null && files2Node.ContainsKey(fileName))
            {
                DictionaryNode entryNode = new DictionaryNode();
                entryNode.Add("hash", new DataNode(sha1Hash));
                entryNode.Add("hash2", new DataNode(sha256Hash));
                files2Node[fileName] = entryNode;
            }
        }