美文网首页
go base32 DecodeString解码错误原因

go base32 DecodeString解码错误原因

作者: 睡着了去做梦 | 来源:发表于2017-05-23 18:20 被阅读0次
    package main
    
    import (
        "encoding/base32"
        "fmt"
        "os"
        "strings"
    )
    
    func main() {
        input := os.Args[1]
        inputnospace := strings.Replace(input, " ", "", -1)
        inputnospaceupper := strings.ToUpper(inputnospace)
        key, err := base32.StdEncoding.DecodeString(inputnospaceupper)
        if err != nil {
            fmt.Println(err)
            return
        }
        fmt.Println(key)
    }
    
    image.png

    错误提示包含指定索引位置,在网上找到了如下答案,只支持A-Z,2-7,=

    Your problem is that that input data isn't Base32 encoded. Base32 encoding only uses the characters A-Z (capital only), 2-7, and =

    相关文章

      网友评论

          本文标题:go base32 DecodeString解码错误原因

          本文链接:https://www.haomeiwen.com/subject/srsgxxtx.html