private void Initialize()
        {
            _keyRing = KeyRing.Load();

            if (!_keyRing.ActiveKeyId.HasValue)
            {
                IDataProtector       protector = _protectors.First();
                EncryptionKeySetting settings  = protector.SetupNew();

                _keyRing.Protectors.Add(settings);
                _keyRing.ActiveKeyId = settings.Id;

                _initializedProtectors.Add(settings.Id, protector);
                KeyRing.Save(_keyRing);
            }
            else
            {
                InitializeProtector(_keyRing.ActiveKeyId.Value);
            }
        }
Beispiel #2
0
        public static void Save(DataProtectorKeyRing keyRing)
        {
            string json = JsonSerializer.Serialize(keyRing);

            File.WriteAllTextAsync(GetPath, json);
        }