Created
March 29, 2023 19:20
-
-
Save powersj/174b06d88c70b4dcdfd2265f311d744b to your computer and use it in GitHub Desktop.
memguard loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"github.com/awnumar/memguard" | |
) | |
func loadSecret(wg *sync.WaitGroup, enclave *memguard.Enclave) { | |
lockbuf, err := enclave.Open() | |
if err != nil { | |
panic(err) | |
} | |
lockbuf.Bytes() | |
lockbuf.Destroy() | |
wg.Done() | |
} | |
func main() { | |
var wg sync.WaitGroup | |
counter := 1 | |
enclave := memguard.NewEnclave([]byte("password")) | |
for { | |
fmt.Printf("loading %d times\n", counter) | |
for i := 0; i < counter; i++ { | |
wg.Add(1) | |
go loadSecret(&wg, enclave) | |
} | |
wg.Wait() | |
counter = counter + 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run with: