func (k Key) FingerprintSHA256() (Fingerprint, error) {
	keyParts := strings.Split(k.Key, " ")
	if len(keyParts) != 2 {
		return Fingerprint{}, ErrMalformedKey
	}
	b, err := base64.StdEncoding.DecodeString(keyParts[1])
	if err != nil {
		return Fingerprint{}, err
	}
	algo := strings.Replace(keyParts[0], "ssh-", "", -1)
	sha256sum := sha256.Sum256(b)
	hash := base64.RawStdEncoding.EncodeToString(sha256sum[:])
	return Fingerprint{
		Algorithm: algo,
		Type:      "SHA256",
		Value:     hash,
	}, nil
}
FingerprintSHA256 returns the algorithm and SHA256 fingerprint for the given
key.
package charm
import (
	"crypto/sha256"
	"encoding/base64"
	"errors"
	"fmt"
	"strings"
	"time"
	"github.com/calmh/randomart"
	"github.com/charmbracelet/charm/ui/common"
)
var ErrMalformedKey = errors.New("malformed key; is it missing the algorithm type at the beginning?")
type Fingerprint struct {
	Algorithm string
	Type      string
	Value     string
}
func (f Fingerprint) String() string {
	return fmt.Sprintf(
		"%s %s",
		common.SubtleIndigoFg(strings.ToUpper(f.Algorithm)),
		common.IndigoFg(f.Type+":"+f.Value),
	)
}
type Key struct {
	Key       string     `json:"key"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
}