Help us shape the future of Go! Take the 2026 Go Developer Survey

qrcode

package
v0.32.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateQRCode

func GenerateQRCode(data string, size int) ([]byte, error)

GenerateQRCode 生成二维码PNG图片 @param data 二维码数据内容 @param size 二维码尺寸(像素) @return []byte PNG图片数据 @return error 错误信息

func GenerateQRCodeBase64

func GenerateQRCodeBase64(data string, size int) (string, error)

GenerateQRCodeBase64 生成Base64编码的二维码图片 @param data 二维码数据内容 @param size 二维码尺寸(像素) @return string Base64编码的PNG图片数据 @return error 错误信息

func GenerateQRCodeID

func GenerateQRCodeID() (string, error)

GenerateQRCodeID 生成二维码唯一ID

⚠️ 2026-10-25 审计 A5:原实现的随机失败兜底是 `fmt.Sprintf("qr_%x", make([]byte, 8))` ⇒ **恒返回常量** "qr_0000000000000000" ⇒ 该分支下所有二维码 ID 相同 ⇒ 存储层 `QRCodeStore[id] = qr` **互相覆盖** ⇒ 先生成的二维码取不到(拿到的是后一个的内容)。

⇒ 随机源失败**显式报错**(不悄悄给一个会撞的 ID):rand.Read 失败意味着 系统熵源异常,此时返回错误比返回"一个会撞的 ID"安全。

@return string 二维码ID @return error 随机源不可用

func ValidateQRCodeData

func ValidateQRCodeData(data string) bool

ValidateQRCodeData 验证二维码数据有效性 @param data 二维码数据 @return bool 是否有效

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL