Because the project needs to use a special encryption and decryption algorithm Golang AES/ECB/PKCS5, but the algorithm is not included in the standard library, after many unsuccessful attempts, finally decoding success, hereby share:
/ * Figure: golang AES / ECB / PKCS5 encryption and decryption date: 2016-04-08 author: herohenu * / package main import ( "bytes" "crypto / aes" "crypto / cipher" "encoding / base64" "fmt" "strings" ) func main () { / * * src string to be encrypted * key The key used for encryption. The key length can be any of 128bit, 192bit, and 256bit. * 16-bit key corresponds to 128bit * / src: = "0.56" key: = "0123456789abcdef" crypted: = AesEncrypt (src, key) AesDecrypt (crypted, [] byte (key)) Base64URLDecode ("39W7dWTd_SBOCM8UbnG6qA") } func Base64URLDecode (data string) ([] byte, error) { var missing = (4-len (data)% 4)% 4 data + = strings.Repeat ("=", missing) res, err: = base64.URLEncoding.DecodeString (data) fmt.Println ("decodebase64urlsafe is:", string (res), err) return base64.URLEncoding.DecodeString (data) } func Base64UrlSafeEncode (source [] byte) string { // Base64 Url Safe