From c9101804ac588dabf491f3c68f1167dc6b46e0f1 Mon Sep 17 00:00:00 2001 From: cblgh Date: Mon, 9 Nov 2026 15:06:39 +0100 Subject: [PATCH] add(util.go): util method SecretBytesFromString intended to be used together with setting the secret key when constructing an endpoint --- util/util.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 util/util.go diff --git a/util/util.go b/util/util.go new file mode 100644 index 0000000..6b7e2c6 --- /dev/null +++ b/util/util.go @@ -0,0 +1,11 @@ +package util + +import ( + "crypto/sha256" +) + +func SecretBytesFromString(str string) []byte { + // TODO (2026-11-09): securely clear all arrays to the extent possible + digest := sha256.Sum256([]byte(str)) + return digest[:] // copy out bytes from strict [32]byte type to []byte used by everything else + iroh +} -- 2.54.0