wip
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
namespace Bitvault;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
public record VaultStorage(string Name, string Password);
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultStorage(IHostEnvironment environment,
|
||||
IDbContextFactory<VaultDbContext> dbContextFactory) :
|
||||
IVaultStorage
|
||||
{
|
||||
public bool Create(string name, VaultKey key)
|
||||
{
|
||||
using VaultDbContext context = dbContextFactory.CreateDbContext();
|
||||
context.Database.SetConnectionString($"Data Source={Path.Combine(environment.ContentRootPath, name)}" +
|
||||
$".vault;Mode=ReadWriteCreate;Password={Convert.ToBase64String(key.Private)}");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user