public override string Transform(string key)
		{
			TigerHash th = new TigerHash();
			byte[] data = th.ComputeHash(Encoding.Unicode.GetBytes(key));

			return Convert.ToBase64String(data, Base64FormattingOptions.None);
		}
示例#2
0
 public override string Transform(string key)
 {
     using (var hasher = new TigerHash())
     {
         return(Convert.ToBase64String(hasher.ComputeHash(Encoding.Unicode.GetBytes(key))));
     }
 }
示例#3
0
        string IMemcachedKeyTransformer.Transform(string key)
        {
            TigerHash th = new TigerHash();

            byte[] data = th.ComputeHash(Encoding.Unicode.GetBytes(key));

            return(Convert.ToBase64String(data, Base64FormattingOptions.None));
        }
        public override string Transform(string key)
        {
            TigerHash th = new TigerHash();

            byte[] data = th.ComputeHash(Encoding.Unicode.GetBytes(key));

            return(Convert.ToBase64String(data));
        }
示例#5
0
        public byte[] EncryptText(EncryptTextMessage message)
        {
            byte[] encryptedText = null;
            //Odradi se enkripcija
            if (message.Algorithm == AlgorithmType.RC4)
            {
                RC4 rc = new RC4(message.Key, message.IV);
                encryptedText = rc.Crypt(message.Data);
            }
            else if (message.Algorithm == AlgorithmType.RC4CTR)
            {
                RC4 rc = new RC4(message.Key, message.IV);
                encryptedText = rc.CryptWithCTR(message.Data);
            }
            else if (message.Algorithm == AlgorithmType.A52 || message.Algorithm == AlgorithmType.A52CTR)
            {
                A52 alg = new A52();
                alg.SetKey(message.Key);
                alg.SetF(message.FKeyA52);

                if (message.Algorithm == AlgorithmType.A52)
                {
                    encryptedText = alg.Crypt(message.Data);
                }
                else
                {
                    alg.SetIV(message.IV);
                    encryptedText = alg.CryptWithCTR(message.Data);
                }
            }
            else if (message.Algorithm == AlgorithmType.RSA)
            {
                RSA rsa = new RSA();
                rsa.E = new BigInteger(message.Key);
                rsa.P = new BigInteger(message.P);
                rsa.Q = new BigInteger(message.Q);
                rsa.GenerateRSA();
                //BigInteger result = rsa.Crypt(new BigInteger(message.Data));
                //encryptedText = result.ToByteArray();
                encryptedText = rsa.Crypt(message.Data);
            }
            else if (message.Algorithm == AlgorithmType.TigerHash)
            {
                TigerHash th  = new TigerHash();
                byte[]    msg = message.Data;
                encryptedText = th.ComputeHash(message.Data);
            }
            return(encryptedText);
        }