FLAGLORD / goaes

an implementation of AES algorithm using golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goaes

an implementation of AES algorithm using golang.

In my implementation, padding uses the PKCS#7, and mode of operation uses the CBC. You can replace these with yours.

中文用户可以在我的博客中了解实现思路。

Usage

If you don't have a aes key, you can create one as follows:

// create a 256-bit key
key, _ := NewAesKey(AES256) 
// you can also create 128-bit, 192-bit
...

Encrypt:

plainText := "hello, world"
cipherText, err := Encrypt(key, []byte(plainText))

Decrypt:

plainText, err := Decrypt(key, cipherText)

You can also copy code in aes.go to your file as it will not import new dependency.

Reference

What is block cipher

About

an implementation of AES algorithm using golang


Languages

Language:Go 100.0%