初版功能完成
ci / Go checks (ubuntu-latest) (push) Has been cancelled
ci / Go checks (windows-latest) (push) Has been cancelled

This commit is contained in:
qsc
2026-08-29 13:12:17 +08:00
commit 142e5dc7d6
217 changed files with 21313 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package clientwg
import (
"encoding/base64"
"fmt"
)
// ParseKeyBase64 parses the standard WireGuard 32-byte base64 key format.
func ParseKeyBase64(value string) (Key, error) {
var key Key
decoded, err := base64.StdEncoding.DecodeString(value)
if err != nil {
return key, fmt.Errorf("decode WireGuard key: %w", err)
}
if len(decoded) != keySize {
return key, fmt.Errorf("WireGuard key decoded length is %d, want %d", len(decoded), keySize)
}
copy(key[:], decoded)
return key, nil
}