示例#1
0
 protected Encryption(byte[] secretKey, byte[] utilitykey, IEncryptBehavior encryptBiavior, IDecryptBehavior decryptBiavior)
 {
     SecretKey       = new BinaryKey(secretKey);
     UtilityKey      = new BinaryKey(utilitykey);
     _encryptBiavior = encryptBiavior;
     _decryptBiavior = decryptBiavior;
 }
示例#2
0
        public void Set(byte[] key, byte[] value)
        {
            BinaryKey binaryKey = new BinaryKey(key);

            BinaryRecord binaryRecord = new BinaryRecord(binaryKey, value);

            int index = KeyHasher.HashKey(binaryKey, BucketArraySize);

            BucketArray.Insert(binaryRecord, index);
        }
示例#3
0
            public override bool Equals(object obj)
            {
                if (!(obj is BinaryKey))
                {
                    return(false);
                }
                BinaryKey other = (BinaryKey)obj;

                return(Helper.AreEqual(key, other.key));
            }
示例#4
0
        public static Assembly LoadAssembly(byte[] binaryAssembly)
        {
            var key = new BinaryKey(binaryAssembly);

            lock (loadedAssemblies)
            {
                Assembly a;
                if (loadedAssemblies.TryGetValue(key, out a))
                {
                    return(a);
                }
                a = AppDomain.CurrentDomain.Load(binaryAssembly);
                loadedAssemblies.Add(key, a);
                return(a);
            }
        }
示例#5
0
        public void Get(byte[] key)
        {
            BinaryKey binaryKey = new BinaryKey(key);

            Record record;

            int index = KeyHasher.HashKey(binaryKey, BucketArraySize);

            try
            {
                record       = BucketArray.Select(binaryKey, index);
                BinaryResult = record.Value;
            }
            catch (NoValueException e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#6
0
 public BinaryRecord(BinaryKey key, string value)
 {
     Key   = key;
     Value = Encoding.UTF8.GetBytes(value);
 }
示例#7
0
 public BinaryRecord(BinaryKey key, byte[] value)
 {
     Key   = key;
     Value = value;
 }