本文實(shí)例講述了go語(yǔ)言實(shí)現(xiàn)AES加密的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
import (
"fmt"
"crypto/aes"
"strings"
)
func main(){
rb:=[]byte {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6};
b:=make([]byte,16);
strings.NewReader("1234567890123456").Read(b);
// b=b[0:16];
fmt.Print("b:",b);
cip,_:= aes.NewCipher(b);
fmt.Print("cip:",cip,"err:");
out:=make([]byte,len(rb));
cip.Encrypt (rb, out);
}
希望本文所述對(duì)大家的Go語(yǔ)言程序設(shè)計(jì)有所幫助。