示例#1
0
        public string Encrypt(string txt, EncryptionKeyUpdated ek)
        {
            string encryptString = string.Empty;

            try
            {
                if (ek.WithEncryption == true)
                {
                    encryptString = (string.IsNullOrEmpty(txt)) ? "" : EncryptText(txt, ek.oSecretKey, ek.oSalt, ek.oKeySize, ek.oAlgorithm);
                }
                else
                {
                    encryptString = txt;
                }
            }
            catch
            {
                encryptString = "ERROR";
            }

            return(encryptString);
        }
示例#2
0
        public EncryptionKeyUpdated EncryptionKey()
        {
            EncryptionKeyUpdated ek = new EncryptionKeyUpdated();

            try
            {
                ek.oSecretKey     = "mySecretKey";
                ek.oSalt          = "mySecretSalt";
                ek.oKeySize       = 256;
                ek.oAlgorithm     = getAlgorithm(ek.oSecretKey, ek.oSalt, ek.oKeySize);
                ek.WithEncryption = true;
            }
            catch
            {
                ek.oSecretKey     = "";
                ek.oSalt          = "";
                ek.oKeySize       = 0;
                ek.oAlgorithm     = new RijndaelManaged();
                ek.WithEncryption = false;
            }

            return(ek);
        }