예제 #1
0
 private static void EncryptTaggedValue(JsonPasswordCrypto cryptoHandler, dynamic valueToEncrypt)
 {
     var value = valueToEncrypt.encrypt.Value;
     var encryptedValue = cryptoHandler.Encrypt(value);
     valueToEncrypt.Replace(JObject.FromObject(encryptedValue));
 }
예제 #2
0
 private static void EncryptJsonValue(JsonPasswordCrypto cryptoHandler, JValue valueToEncrypt)
 {
     var value = valueToEncrypt.Value<string>();
     var encryptedValue = cryptoHandler.Encrypt(value);
     valueToEncrypt.Replace(JObject.FromObject(encryptedValue));
 }
예제 #3
0
        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);
            }
        }