func (k *Key) AccountName() string {
	p := strings.TrimPrefix(k.url.Path, "/")
	i := strings.Index(p, ":")
	if i == -1 {
		return p
	}
	return p[i+1:]
}
AccountName returns the name of the user's account.
package otp
import (
	"github.com/boombuler/barcode"
	"github.com/boombuler/barcode/qr"
	"crypto/md5"
	"crypto/sha1"
	"crypto/sha256"
	"crypto/sha512"
	"errors"
	"fmt"
	"hash"
	"image"
	"net/url"
	"strings"
)
var ErrValidateSecretInvalidBase32 = errors.New("Decoding of secret as base32 failed.")
var ErrValidateInputInvalidLength = errors.New("Input length unexpected")
var ErrGenerateMissingIssuer = errors.New("Issuer must be set")
var ErrGenerateMissingAccountName = errors.New("AccountName must be set")
type Key struct {
	orig string
	url  *url.URL
}
func NewKeyFromURL(orig string) (*Key, error) {
	s := strings.TrimSpace(orig)
	u, err := url.Parse(s)
	if err != nil {
		return nil, err
	}
	return &Key{
		orig: s,
		url:  u,
	}, nil
}
func (k *Key) String() string {
	return k.orig
}
func (k *Key) Image(width int, height int) (image.Image, error) {
	b, err := qr.Encode(k.orig, qr.M, qr.Auto)
	if err != nil {
		return nil, err
	}
	b, err = barcode.Scale(b, width, height)
	if err != nil {
		return nil, err
	}
	return b, nil
}
func (k *Key) Type() string {
	return k.url.Host
}
func (k *Key) Issuer() string {
	q := k.url.Query()
	issuer := q.Get("issuer")
	if issuer != "" {
		return issuer
	}
	p := strings.TrimPrefix(k.url.Path, "/")
	i := strings.Index(p, ":")
	if i == -1 {
		return ""
	}
	return p[:i]
}