func (k *Key) Type() string {
	return k.url.Host
}
Type returns "hotp" or "totp".
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
}