source: trunk/CrypPlugins/KeySearcher/P2P/Storage/StorageKeyGenerator.cs @ 1693

Last change on this file since 1693 was 1674, checked in by Paul Lelgemann, 12 years ago

o Refactored distributed KeySearcher: updated directory structure and variable names

File size: 1.2 KB
Line 
1using System;
2using System.Security.Cryptography;
3using System.Text;
4
5namespace KeySearcher.P2P.Storage
6{
7    class StorageKeyGenerator
8    {
9        private readonly KeySearcher keySearcher;
10        private readonly KeySearcherSettings settings;
11
12        public StorageKeyGenerator(KeySearcher keySearcher, KeySearcherSettings settings)
13        {
14            this.keySearcher = keySearcher;
15            this.settings = settings;
16           
17        }
18
19        public String Generate()
20        {
21            var rawIdentifier = "P2PJOB";
22            rawIdentifier += settings.ChunkSize + settings.Key;
23            rawIdentifier += keySearcher.ControlMaster.GetType();
24            rawIdentifier += keySearcher.CostMaster.GetType();
25            rawIdentifier += keySearcher.CostMaster.getBytesToUse();
26            rawIdentifier += keySearcher.CostMaster.getRelationOperator();
27            rawIdentifier += Encoding.ASCII.GetString(keySearcher.EncryptedData);
28
29            var hashAlgorithm = new SHA1CryptoServiceProvider();
30            var hash = hashAlgorithm.ComputeHash(Encoding.ASCII.GetBytes(rawIdentifier));
31            return BitConverter.ToString(hash).Replace("-", "");
32        }
33    }
34}
Note: See TracBrowser for help on using the repository browser.