2023-09-10 15:39:34 +00:00
|
|
|
package lib
|
2023-09-09 20:52:50 +00:00
|
|
|
|
2023-09-09 20:52:51 +00:00
|
|
|
import (
|
|
|
|
"encoding/base64"
|
|
|
|
|
|
|
|
"github.com/skip2/go-qrcode"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ToQR(s string) (string, error) {
|
|
|
|
png, err := qrcode.Encode(s, qrcode.Medium, 256)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
qr := base64.StdEncoding.EncodeToString([]byte(png))
|
|
|
|
return qr, nil
|
|
|
|
}
|