示例#1
0
文件: totp.go 项目: kisom/cryptutils
// ExportQR returns a QR code as a PNG for the TOTP token.
func (config *TOTPConfig) ExportQR(label string) ([]byte, error) {
	u := config.generateURL(label)
	code, err := qr.Encode(u, qr.Q)
	if err != nil {
		return nil, err
	}
	return code.PNG(), nil
}
示例#2
0
文件: oath.go 项目: kisom/cryptutils
// QR generates a byte slice containing the a QR code encoded as a
// PNG with level Q error correction.
func (o OATH) QR(t Type, label string) ([]byte, error) {
	u := o.URL(t, label)
	code, err := qr.Encode(u, qr.Q)
	if err != nil {
		return nil, err
	}
	return code.PNG(), nil
}