Exemplo n.º 1
0
 private ProtectedPrivateKey Get(string name)
 {
     using (StreamReader reader = new StreamReader(System.IO.Path.Combine(Path, name)))
     {
         return(ProtectedPrivateKey.FromJson(reader.ReadToEnd()));
     }
 }
Exemplo n.º 2
0
        public Guid Add(ProtectedPrivateKey key)
        {
            if (key is null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            Guid   keyId    = Guid.NewGuid();
            string filename = string.Format(
                CultureInfo.InvariantCulture,
                NameFormat,
                DateTimeOffset.UtcNow,
                keyId
                );
            var keyPath = System.IO.Path.Combine(Path, filename);

            using Stream f = new FileStream(keyPath, FileMode.CreateNew);
            key.WriteJson(f, keyId);
            return(keyId);
        }