go-sm4
golang sm4 encrypt
' ██████╗ ██████╗ ███████╗███╗ ███╗██╗ ██╗
' ██╔════╝ ██╔═══██╗ ██╔════╝████╗ ████║██║ ██║
' ██║ ███╗██║ ██║█████╗███████╗██╔████╔██║███████║
' ██║ ██║██║ ██║╚════╝╚════██║██║╚██╔╝██║╚════██║
' ╚██████╔╝╚██████╔╝ ███████║██║ ╚═╝ ██║ ██║
' ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝
Use go get
to install and update:
$ go get -u github.com/scloudrun/go-sm4
# assume the following codes in example.go file
$ cat example.go
package main
import (
"fmt"
sm4lib "github.com/scloudrun/go-sm4"
)
var (
defaultKey = []byte("0000000000000000")
defaultIv = []byte("1111111111111111")
defaultEncData = []byte("scloudrun")
defaultEncByte = []byte{54, 214, 183, 79, 105, 233, 133, 146, 228, 57, 231, 154, 21, 241, 170, 7}
)
func main() {
fmt.Println(sm4lib.Sm4Enc(defaultKey,defaultIv,defaultEncData,true))
}
# run example.go
$ go run example.go
- extend