Esempio n. 1
0
        public static ICryptoValue Encrypt(RcTypes type, byte[] originalBytes, byte[] pwd)
        {
            var key      = Factory.GenerateKey(pwd);
            var function = Factory.Create(type, key);

            return(function.Encrypt(originalBytes));
        }
Esempio n. 2
0
        public static ICryptoValue Decrypt(RcTypes type, byte[] cipherBytes, byte[] pwd)
        {
            var key      = Factory.GenerateKey(pwd);
            var function = Factory.Create(type, key);

            return(function.Decrypt(cipherBytes));
        }
Esempio n. 3
0
        public static ICryptoValue Decrypt(RcTypes type, string cipherText, string pwd, CipherTextTypes cipherTextType, Encoding encoding = null, Func <string, byte[]> customConverter = null)
        {
            encoding = encoding.SafeEncodingValue();
            var key      = Factory.GenerateKey(pwd, encoding);
            var function = Factory.Create(type, key);

            return(function.Decrypt(cipherText, cipherTextType, encoding, customConverter));
        }
Esempio n. 4
0
        public static ICryptoValue Decrypt(RcTypes type, string cipherText, string pwd, Encoding encoding = null)
        {
            encoding = encoding.SafeEncodingValue();
            var key      = Factory.GenerateKey(pwd, encoding);
            var function = Factory.Create(type, key);

            return(function.Decrypt(cipherText, encoding));
        }
Esempio n. 5
0
        public static IRC Create(RcTypes type, RcKey key)
        {
            switch (type)
            {
            case RcTypes.RC4:
                return(new RC4Function(key));

            case RcTypes.RCX:
                return(new RCXFunction(key));

            case RcTypes.RCY:
                return(new RCYFunction(key));

            case RcTypes.ThreeRCX:
                return(new ThreeRCXFunction(key));

            case RcTypes.ThreeRCY:
                return(new ThreeRCYFunction(key));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Esempio n. 6
0
        public static IRC Create(RcTypes type, string pwd, Encoding encoding = null)
        {
            switch (type)
            {
            case RcTypes.RC4:
                return(new RC4Function(GenerateKey(pwd, encoding)));

            case RcTypes.RCX:
                return(new RCXFunction(GenerateKey(pwd, encoding)));

            case RcTypes.RCY:
                return(new RCYFunction(GenerateKey(pwd, encoding)));

            case RcTypes.ThreeRCX:
                return(new ThreeRCXFunction(GenerateKey(pwd, encoding)));

            case RcTypes.ThreeRCY:
                return(new ThreeRCYFunction(GenerateKey(pwd, encoding)));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Esempio n. 7
0
 public static IRC Create(RcTypes type, RcKey key) => Factory.Create(type, key);
Esempio n. 8
0
 public static IRC Create(RcTypes type, byte[] pwd) => Factory.Create(type, pwd);
Esempio n. 9
0
 public static IRC Create(RcTypes type, string pwd, Encoding encoding = null) => Factory.Create(type, pwd, encoding);
Esempio n. 10
0
 public static IRC Create(RcTypes type) => Factory.Create(type);