go base32 DecodeString解码错误原因
2017-05-23 本文已影响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)
}

错误提示包含指定索引位置,在网上找到了如下答案,只支持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 =