Lightweight and easily self-hostable Git forge. git.poy.ooo
git-forge selfhosting homebrew
Something went wrong. Try again.
12345678910111213141516171819202122232425262728package lib
import ( "strings"
"golang.org/x/crypto/ssh")
type SSHPubKey struct { Key string Algorithm string Fingerprint string}
// Parses a public key and returns it in a nice struct.func ParseKey(keyText string) (key SSHPubKey, err error) { pubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(keyText)) if err != nil { return SSHPubKey{}, err }
return SSHPubKey{ Key: strings.TrimSpace(string(ssh.MarshalAuthorizedKey(pubKey))), Algorithm: pubKey.Type(), Fingerprint: ssh.FingerprintSHA256(pubKey), }, nil}