Ejemplo n.º 1
0
        public CryptoHashCodeTable(string seed)
        {
            _HashCodes = new CryptoHashCode[CryptoService.Providers.Length];

            foreach (CryptoHashCodeProvider hcp in CryptoService.Providers)
            {
                _HashCodes[hcp.ProviderID] = CryptoGenerator.GenHashCode(hcp.ProviderID, seed);
            }

            _ExtendedHashCodes = new Dictionary <int, CryptoHashCode>(CryptoService.ExtendedProviders.Count);

            foreach (CryptoHashCodeProvider hcp in CryptoService.ExtendedProviders.Values)
            {
                if (_ExtendedHashCodes.ContainsKey(hcp.ProviderID))
                {
                    _ExtendedHashCodes[hcp.ProviderID] = CryptoGenerator.GenHashCode(hcp.ProviderID, seed);
                }
                else
                {
                    _ExtendedHashCodes.Add(hcp.ProviderID, CryptoGenerator.GenHashCode(hcp.ProviderID, seed));
                }
            }

            _UID = GenerateUID(this);
        }
Ejemplo n.º 2
0
        public virtual void Deserialize(GenericReader reader)
        {
            var version = reader.GetVersion();

            ProviderID = reader.ReadInt();

            switch (version)
            {
            case 2:
            {
                Value      = reader.ReadString();
                _ValueHash = reader.ReadInt();
            }
            break;

            case 1:
            {
                var seed = reader.ReadBool()
                                                ? StringCompression.Unpack(reader.ReadBytes())
                                                : Encoding.UTF32.GetString(reader.ReadBytes());

                Value = CryptoGenerator.GenString(ProviderID, seed ?? String.Empty);
            }
            break;

            case 0:
            {
                var seed = reader.ReadString();

                Value = CryptoGenerator.GenString(ProviderID, seed ?? String.Empty);
            }
            break;
            }
        }
Ejemplo n.º 3
0
        public virtual void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                _ProviderID = reader.ReadInt();
                _Seed       = reader.ReadString();
                _Value      = CryptoGenerator.GenString(_ProviderID, _Seed);
            }
            break;
            }
        }
Ejemplo n.º 4
0
        public CryptoHashCode(int providerID, string seed)
        {
            ProviderID = providerID;

            Value = CryptoGenerator.GenString(ProviderID, seed ?? String.Empty);
        }
Ejemplo n.º 5
0
 public CryptoHashCode(int providerID, string seed)
 {
     _Seed       = seed;
     _ProviderID = providerID;
     _Value      = CryptoGenerator.GenString(_ProviderID, _Seed);
 }
Ejemplo n.º 6
0
 public CryptoHashCode(CryptoHashType type, string seed)
 {
     _Seed       = seed;
     _ProviderID = (int)type;
     _Value      = CryptoGenerator.GenString(type, _Seed);
 }
Ejemplo n.º 7
0
 public CryptoHashCodeTable(string seed)
 {
     AddRange(CryptoService.Providers.Keys.Select(type => CryptoGenerator.GenHashCode(type, seed)));
 }
Ejemplo n.º 8
0
 public static CryptoHashCode GenerateUID(CryptoHashCodeTable table)
 {
     return(CryptoGenerator.GenHashCode(CryptoHashType.MD5, String.Join("+", table)));
 }