mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-21 16:43:55 +08:00
6dd096b7f0
* Initial commit for 2FA support Signed-off-by: Andrew <write@imaginarycode.com> * Add vendored files * Add missing depends * A few clean ups * Added improvements, proper encryption * Better encryption key * Simplify "key" generation * Make 2FA enrollment page more robust * Fix typo * Rename twofa/2FA to TwoFactor * UNIQUE INDEX -> UNIQUE
24 lines
573 B
Go
Vendored
24 lines
573 B
Go
Vendored
package qr
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/boombuler/barcode/utils"
|
|
)
|
|
|
|
func encodeAuto(content string, ecl ErrorCorrectionLevel) (*utils.BitList, *versionInfo, error) {
|
|
bits, vi, _ := Numeric.getEncoder()(content, ecl)
|
|
if bits != nil && vi != nil {
|
|
return bits, vi, nil
|
|
}
|
|
bits, vi, _ = AlphaNumeric.getEncoder()(content, ecl)
|
|
if bits != nil && vi != nil {
|
|
return bits, vi, nil
|
|
}
|
|
bits, vi, _ = Unicode.getEncoder()(content, ecl)
|
|
if bits != nil && vi != nil {
|
|
return bits, vi, nil
|
|
}
|
|
return nil, nil, fmt.Errorf("No encoding found to encode \"%s\"", content)
|
|
}
|