private static void EncryptTaggedValue(JsonPasswordCrypto cryptoHandler, dynamic valueToEncrypt) { var value = valueToEncrypt.encrypt.Value; var encryptedValue = cryptoHandler.Encrypt(value); valueToEncrypt.Replace(JObject.FromObject(encryptedValue)); }
private static void EncryptJsonValue(JsonPasswordCrypto cryptoHandler, JValue valueToEncrypt) { var value = valueToEncrypt.Value<string>(); var encryptedValue = cryptoHandler.Encrypt(value); valueToEncrypt.Replace(JObject.FromObject(encryptedValue)); }
private static void EncryptTaggedValue(JsonPasswordCrypto cryptoHandler, KeyValuePair<YamlMappingNode, YamlNode> containerKeyPair) { var container = containerKeyPair.Key; var key = containerKeyPair.Value; var value = container.Children[key].ToString(); var encryptedValue = cryptoHandler.Encrypt(value); container.Children.Remove(key); var serializer = new Serializer(); using (var writer = new StringWriter()) { serializer.Serialize(writer, encryptedValue); var stream = new YamlStream(); stream.Load(new StringReader(writer.ToString())); stream.Documents[0].RootNode.Tag = "tag:yaml.org,2002:encrypted"; container.Add(key, stream.Documents[0].RootNode); } }