@@ -78,4 +78,52 @@ func main() {
7878 return
7979 }
8080 fmt .Println ("plaintext:" , plaintext )
81+
82+ // encrypt the data with AES-128 in GCM using EncryptAesGcmWithNonceAppended function
83+ ciphertext128 , err = crypt .EncryptAesGcmWithNonceAppended (key128 , text )
84+ if err != nil {
85+ fmt .Println (err )
86+ return
87+ }
88+ fmt .Println ("ciphertext (AES-128):" , ciphertext128 )
89+
90+ // decrypt the data with AES-128 in GCM using DecryptAesGcmWithNonceAppended function
91+ plaintext , err = crypt .DecryptAesGcmWithNonceAppended (key128 , ciphertext128 )
92+ if err != nil {
93+ fmt .Println (err )
94+ return
95+ }
96+ fmt .Println ("plaintext:" , plaintext )
97+
98+ // encrypt the data with AES-192 in GCM using EncryptAesGcmWithNonceAppended function
99+ ciphertext192 , err = crypt .EncryptAesGcmWithNonceAppended (key192 , text )
100+ if err != nil {
101+ fmt .Println (err )
102+ return
103+ }
104+ fmt .Println ("ciphertext (AES-192):" , ciphertext192 )
105+
106+ // decrypt the data with AES-192 in GCM using DecryptAesGcmWithNonceAppended function
107+ plaintext , err = crypt .DecryptAesGcmWithNonceAppended (key192 , ciphertext192 )
108+ if err != nil {
109+ fmt .Println (err )
110+ return
111+ }
112+ fmt .Println ("plaintext:" , plaintext )
113+
114+ // encrypt the data with AES-256 in GCM using EncryptAesGcmWithNonceAppended function
115+ ciphertext256 , err = crypt .EncryptAesGcmWithNonceAppended (key256 , text )
116+ if err != nil {
117+ fmt .Println (err )
118+ return
119+ }
120+ fmt .Println ("ciphertext (AES-256):" , ciphertext256 )
121+
122+ // decrypt the data with AES-256 in GCM using DecryptAesGcmWithNonceAppended function
123+ plaintext , err = crypt .DecryptAesGcmWithNonceAppended (key256 , ciphertext256 )
124+ if err != nil {
125+ fmt .Println (err )
126+ return
127+ }
128+ fmt .Println ("plaintext:" , plaintext )
81129}
0 commit comments