golang base64编解码

@bolun365
package main

import (
    "encoding/base64"
    "io/ioutil"
)   

const (
    base64Table = "123QRSTUabcdVWXYZHijKLAWDCABDstEFGuvwxyzGHIJklmnopqr234560178912"
)   

var coder = base64.NewEncoding(base64Table)

func base64Encode(src []byte) string {
    return coder.EncodeToString(src) 
}   

func base64Decode(src string) ([]byte, error) {
    return coder.DecodeString(src)
}   

func main() {
    rawData, _ := ioutil.ReadFile("1.pcap")

    // encode
    encodeData := base64Encode(rawData)

    // decode
    //decodeData, err := base64Decode(encodeData)

    //fmt.Println(string(decodeData))
}   

你可能感兴趣的:(golang)