WireGuard / wgctrl-go

Package wgctrl enables control of WireGuard interfaces on multiple platforms.
https://godoc.org/golang.zx2c4.com/wireguard/wgctrl
MIT License
730 stars 85 forks source link

wgtypes: Add ParseKey(string) function #29

Closed the-maldridge closed 5 years ago

the-maldridge commented 5 years ago

Right now its easy to get from a key to a string, but its non-trivial to get from a string to a key. Given that this is a common transform if coming from something like JSON, or protobuf, it would be much more convenient if there was a builtin to get a key out of a string.

mdlayher commented 5 years ago

Seems just fine to me. I think the logical option would be to specifically parse base64-encoded keys, since those are what are produced by the String method.

I had to look it over again, but hex keys are used internally in the userspace configuration protocol. These aren't publicly exposed though, so I think that if someone really wants hex, they can just call the requisite stdlib functions on the Key themselves.