本文实例讲述了go语言实现AES加密的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
package main
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);
}
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);
}
希望本文所述对大家的Go语言程序设计有所帮助。