示例#1
0
        public string GetEncryptedString(MapConfigEntry entry)
        {
            Type t = entry.Default.GetType();

            if (!(t == typeof(string) || t == typeof(String)))
            {
                throw new Exception("GetEncryptedString only works on string entries.");
            }

            string result = string.Empty;

            try
            {
                result = StringCrypt.DecryptString((string)GetValue(entry), _cryptPass);
                if (result != string.Empty)
                {
                    if (result.StartsWith(_cryptCheck))
                    {
                        result = result.Replace(_cryptCheck, string.Empty);
                    }
                    else
                    {
                        result = string.Empty;
                    }
                }
            }
            catch
            {
                result = string.Empty;
            }

            return(result);
        }
示例#2
0
        public void SetEncryptedString(MapConfigEntry entry, string value)
        {
            Type t = entry.Default.GetType();

            if (!(t == typeof(string) || t == typeof(String)))
            {
                throw new Exception("SetEncryptedString only works on string entries.");
            }

            SetValue(entry, StringCrypt.EncryptString(_cryptCheck + value, _cryptPass));
        }