Ejemplo n.º 1
0
        public static string Open(string filename, EncryptionType et)
        {
            BinaryReader br  = new BinaryReader(new FileStream(filename, FileMode.Open));
            List <byte>  _in = new List <byte>();

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                _in.Add(br.ReadByte());
            }
            br.Close();
            if (et == EncryptionType.AES)
            {
                return(Utilities.ByteToString(AESProvider.Decrypt(_in.ToArray())));
            }
            if (et == EncryptionType.ASCII)
            {
                return(ASCIIProvider.Decrypt(Utilities.ByteToString(_in.ToArray())));
            }
            if (et == EncryptionType.DES)
            {
                return(Utilities.ByteToString(DESProvider.Decrypt(_in.ToArray())));
            }
            if (et == EncryptionType.L1F3)
            {
                return(L1F3Provider.Decrypt(_in.ToArray()));
            }
            if (et == EncryptionType.RC2)
            {
                return(Utilities.ByteToString(RC2Provider.Decrypt(_in.ToArray())));
            }
            if (et == EncryptionType.Rijndael)
            {
                return(Utilities.ByteToString(RijndaelProvider.Decrypt(_in.ToArray())));
            }
            if (et == EncryptionType.RSA)
            {
                return(Utilities.ByteToString(RSAProvider.Decrypt(_in.ToArray())));
            }
            if (et == EncryptionType.TripleDES)
            {
                return(Utilities.ByteToString(TripleDESProvider.Decrypt(_in.ToArray())));
            }
            if (et == EncryptionType.Xor)
            {
                return(AESProvider.Decrypt(Utilities.ByteToString(_in.ToArray())));
            }
            throw new Exception("Invalid decryption type!");
        }
Ejemplo n.º 2
0
        public static LuaValue Decrypt(LuaValue[] args)
        {
            string decType = (args[0] as LuaString).Text.ToLower();
            string _in     = args[1].ToString();

            if (decType == "aes")
            {
                return(new LuaString(AESProvider.Decrypt(_in)));
            }
            else if (decType == "ascii")
            {
                // Decrypt with first byte of key
                return(new LuaString(ASCIIProvider.Decrypt(_in)));
            }
            if (decType == "des")
            {
                return(new LuaString(DESProvider.Decrypt(_in)));
            }
            if (decType == "rc2")
            {
                return(new LuaString(RC2Provider.Decrypt(_in)));
            }
            if (decType == "rijndael")
            {
                return(new LuaString(RijndaelProvider.Decrypt(_in)));
            }
            if (decType == "rsa")
            {
                return(new LuaString(RSAProvider.Decrypt(_in)));
            }
            if (decType == "tripledes")
            {
                return(new LuaString(TripleDESProvider.Decrypt(_in)));
            }
            if (decType == "xor")
            {
                return(new LuaString(XorProvider.Decrypt(_in)));
            }
            throw new Exception("Unsuported Decryption '" + decType + "'!");
        }