コード例 #1
0
 public EncodDecodEventArgs(EncryptionEnum processType, Coder coderType, string text, string passwordKey)
 {
     ProcessType = processType;
     Key         = passwordKey;
     Text        = text;
     CoderType   = coderType;
 }
コード例 #2
0
        private StringContent ContentEncryption(string content, EncryptionEnum encryption)
        {
            if (!string.IsNullOrEmpty(content))
            {
                var tokens = new List <JToken>();

                var token = JToken.Parse(content);

                FindTokens(token, "id", tokens);
                FindTokens(token, "ids", tokens);

                foreach (var value in tokens)
                {
                    if (value.Type == JTokenType.Array)
                    {
                        foreach (JValue value2 in value)
                        {
                            ValueEncryption(value2, encryption);
                        }
                    }
                    else if (value.Type == JTokenType.Integer ||
                             value.Type == JTokenType.String ||
                             value.Type == JTokenType.Guid)
                    {
                        ValueEncryption((JValue)value, encryption);
                    }
                }

                return(new StringContent(JsonConvert.SerializeObject(token), Encoding.UTF8, "application/json"));
            }
            else
            {
                return(new StringContent(string.Empty, Encoding.UTF8, "application/json"));
            }
        }
コード例 #3
0
 public EncodDecodEventArgs(EncryptionEnum processType, Coder coderType, string text, int key1, int key2)
 {
     ProcessType = processType;
     Text        = text;
     KeyOne      = key1 == 0 ? 3: key1;
     KeyTwo      = key2 == 0 ? 5 : key2;
     CoderType   = coderType;
 }
コード例 #4
0
 private void ValueEncryption(JValue value, EncryptionEnum encryption)
 {
     if (value.Value != null)
     {
         if (encryption == EncryptionEnum.Encrypt)
         {
             value.Value = DependencyRegistar.Resolve <ICryptographicService>().GetEncryptedValue(value.Value.ToString());
         }
         else
         {
             value.Value = DependencyRegistar.Resolve <ICryptographicService>().GetDecryptedValue(value.Value.ToString());
         }
     }
 }
コード例 #5
0
ファイル: Presenter.cs プロジェクト: pessoft/ProjectSecurity
        private void ProcessText(EncryptionEnum processType, IEncryption coder, string text)
        {
            string result = string.Empty;

            switch (processType)
            {
            case EncryptionEnum.Encoding:
                result = coder.Encoding(text);
                break;

            case EncryptionEnum.Decoding:
                result = coder.Decoding(text);
                break;
            }

            view.SetOutText(result);
        }