예제 #1
0
파일: MapConfig.cs 프로젝트: rioniac/Elpis
        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
파일: MapConfig.cs 프로젝트: rioniac/Elpis
        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));
        }