public EncodDecodEventArgs(EncryptionEnum processType, Coder coderType, string text, string passwordKey) { ProcessType = processType; Key = passwordKey; Text = text; CoderType = coderType; }
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")); } }
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; }
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()); } } }
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); }