Esempio n. 1
0
// 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
}
Esempio n. 2
0
// 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
}