static void GetFile()
		{
			EncryptionType et;
			GetResponse resp = conn.get(bucket, GetFilename(path, ".file"), null);
			string encryptionMethod = resp.Connection.Headers["x-amz-meta-crypt"];
			string encryptionSalt = resp.Connection.Headers["x-amz-meta-crypt-salt"];
			if (encryptionSalt == null)
				encryptionSalt = path.ToLower();
			else
				encryptionSalt = Uri.UnescapeDataString(encryptionSalt);
			if (encryptionMethod.StartsWith("rc4"))
				et = EncryptionType.etRC4;
			else if (encryptionMethod.StartsWith("aes"))
				et = EncryptionType.etAES;
			else et = EncryptionType.etNone;

			Stream s = resp.GetResponseStream();
			RC4 rc4 = new RC4();
			string keyString = secretKey + encryptionSalt;
			Rijndael aes = RijndaelManaged.Create();
			int blockIndex = 0;
			int blockOffset = 0;
			byte[] ivec = null;
			byte[] evec = null;
			byte[] key;
			if (et != EncryptionType.etNone)
			{
				int keylen = (et == EncryptionType.etAES) ? 32 : 16;
				key = new byte[keylen];
				rc4.EVP_BytesToKey(new byte[0], Encoding.Default.GetBytes(keyString), 1, key, new byte[0]);
				if (et == EncryptionType.etAES)
				{
					aes.Mode = CipherMode.ECB;
					aes.Key = key;
					blockIndex = 0;
					blockOffset = 0;
					ivec = (new MD5CryptoServiceProvider()).ComputeHash(Encoding.Default.GetBytes(encryptionSalt));
					evec = new byte[ivec.Length];

				} else
				{
					rc4.Init(key);
				}
			}

			using (FileStream fs = File.OpenWrite(localfile))
			{
				byte[] buffer = new byte[1024];
				while (true)
				{
					int nread = s.Read(buffer, 0, buffer.Length);
					if (nread == 0)
						return;
					byte[] decrypt = (et == EncryptionType.etAES) ? AESCTREncrypt(aes.CreateEncryptor(), buffer, nread, ivec, evec, ref blockIndex, ref blockOffset) :
						(et == EncryptionType.etRC4) ? rc4.Encrypt(buffer, nread) : buffer;
					fs.Write(decrypt, 0, nread);
				}
			}			
		}
        static void GetFile()
        {
            EncryptionType et;
            GetResponse    resp             = conn.get(bucket, GetFilename(path, ".file"), null);
            string         encryptionMethod = resp.Connection.Headers["x-amz-meta-crypt"];
            string         encryptionSalt   = resp.Connection.Headers["x-amz-meta-crypt-salt"];

            if (encryptionSalt == null)
            {
                encryptionSalt = path.ToLower();
            }
            else
            {
                encryptionSalt = Uri.UnescapeDataString(encryptionSalt);
            }
            if (encryptionMethod.StartsWith("rc4"))
            {
                et = EncryptionType.etRC4;
            }
            else if (encryptionMethod.StartsWith("aes"))
            {
                et = EncryptionType.etAES;
            }
            else
            {
                et = EncryptionType.etNone;
            }

            Stream   s           = resp.GetResponseStream();
            RC4      rc4         = new RC4();
            string   keyString   = secretKey + encryptionSalt;
            Rijndael aes         = RijndaelManaged.Create();
            int      blockIndex  = 0;
            int      blockOffset = 0;

            byte[] ivec = null;
            byte[] evec = null;
            byte[] key;
            if (et != EncryptionType.etNone)
            {
                int keylen = (et == EncryptionType.etAES) ? 32 : 16;
                key = new byte[keylen];
                rc4.EVP_BytesToKey(new byte[0], Encoding.Default.GetBytes(keyString), 1, key, new byte[0]);
                if (et == EncryptionType.etAES)
                {
                    aes.Mode    = CipherMode.ECB;
                    aes.Key     = key;
                    blockIndex  = 0;
                    blockOffset = 0;
                    ivec        = (new MD5CryptoServiceProvider()).ComputeHash(Encoding.Default.GetBytes(encryptionSalt));
                    evec        = new byte[ivec.Length];
                }
                else
                {
                    rc4.Init(key);
                }
            }

            using (FileStream fs = File.OpenWrite(localfile))
            {
                byte[] buffer = new byte[1024];
                while (true)
                {
                    int nread = s.Read(buffer, 0, buffer.Length);
                    if (nread == 0)
                    {
                        return;
                    }
                    byte[] decrypt = (et == EncryptionType.etAES) ? AESCTREncrypt(aes.CreateEncryptor(), buffer, nread, ivec, evec, ref blockIndex, ref blockOffset) :
                                     (et == EncryptionType.etRC4) ? rc4.Encrypt(buffer, nread) : buffer;
                    fs.Write(decrypt, 0, nread);
                }
            }
        }