load cfg from file, encrypt for given peers

This commit is contained in:
2024-08-14 10:59:34 +02:00
parent a5dda01654
commit 6502bb1e12
2 changed files with 64 additions and 53 deletions

View File

@@ -47,10 +47,10 @@ func main() {
fmt.Printf("AgeKey: %s\n", key.String())
fmt.Printf("AgePublicKey: %s\n", key.Recipient().String())
cipher, err := age.Encrypt([]byte("Test Message"), []string{key.Recipient().String()})
fmt.Printf("Encrypted: %s\n", cipher)
decrypted, err := age.Decrypt(cipher, key)
fmt.Printf("Decrypted: %s\n", decrypted)
//cipher, err := age.Encrypt([]byte("Test Message"), []string{key.Recipient().String()})
//fmt.Printf("Encrypted: %s\n", cipher)
//decrypted, err := age.Decrypt(cipher, key)
//fmt.Printf("Decrypted: %s\n", decrypted)
h, dht, err := storage.SetupLibp2pHost(ctx, *dbPath)
@@ -84,6 +84,12 @@ func main() {
logger.Fatal(err)
}
Cfg, err := storage.NewConfig(*dbPath + "/config.json")
if err != nil {
logger.Fatal(err)
}
storageHandler := storage.StorageHandler{
Ctx: ctx ,
Store: store,
@@ -91,10 +97,9 @@ func main() {
Ipfs: ipfs,
PubSub: ps,
Key: key,
Config: Cfg,
}
Cfg := storage.NewConfig()
Namespaces := make(map[string]*storage.Namespace)
for _, nsCfg := range Cfg {
ns1, err := storage.CreateNamespace(nsCfg.Id, storageHandler)
@@ -254,7 +259,7 @@ Commands:
continue
}
encryptedPassword, err := age.Encrypt(data, []string{key.Recipient().String()})
encryptedPassword, err := age.Encrypt(data, val.GetRecipients())
if err != nil {
printErr(err)
continue