A simple .NET library to manage cryptographic keys.
Show/hide folder structure
.
├── .github
│ └── workflows
├── Devantler.KeyManager.Core
│ └── Models
├── Devantler.KeyManager.Local.Age
└── Devantler.KeyManager.Local.Age.Tests
└── LocalAgeKeyManagerTests
7 directories
To get started, you can install the packages from NuGet.
# For the Age key model
dotnet add package Devantler.KeyManager.Local.Age
If you need to create a new implementation for a key manager, you can install the core package.
dotnet add package Devantler.Keys.Core
The Local Age Key Manager is a simple key manager to manage Age keys on your local machine. The key manager saves and loads keys from your SOPS keyring by default.
To create a new key, you can use the CreateKeyAsync
method.
using Devantler.KeyManager.Local.Age;
var keyManager = new LocalAgeKeyManager();
var key = await keyManager.CreateKeyAsync();
To delete a key, you can use the DeleteKeyAsync
method.
using Devantler.Keys.Age;
using Devantler.KeyManager.Local.Age;
var keyManager = new LocalAgeKeyManager();
var ageKey = AgeKeygen.InMemory();
await keyManager.DeleteKeyAsync(ageKey);
To get an existing key, you can use the GetKeyAsync
method.
using Devantler.KeyManager.Local.Age;
var keyManager = new LocalAgeKeyManager();
var key = await keyManager.GetKeyAsync("<public key>");
To import a key, you can use the ImportKeyAsync
method.
using Devantler.Keys.Age;
using Devantler.KeyManager.Local.Age;
var keyManager = new LocalAgeKeyManager();
var ageKey = AgeKeygen.InMemory();
var key = await keyManager.ImportKeyAsync(ageKey);
To check if a key exists, you can use the KeyExistsAsync
method.
using Devantler.KeyManager.Local.Age;
var keyManager = new LocalAgeKeyManager();
var exists = await keyManager.KeyExistsAsync("<public key>");
To list all keys, you can use the ListKeysAsync
method.
using Devantler.KeyManager.Local.Age;
var keyManager = new LocalAgeKeyManager();
var keys = await keyManager.ListKeysAsync();