The go language implements the method of AES encryption

  • 2020-05-27 05:49:34
  • OfStack

This article illustrates how the go language implements AES encryption. Share with you for your reference. The specific implementation method is as follows:

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);
}

I hope this article has been helpful to your programming of Go language.


Related articles: