ret := 0
key := []byte("1234567890abcdef")
iv := []byte("1234567890abcdef")
orig := []byte("hello world!")
ret = Sm4CbcEncrypt(orig,cipherText,key,iv)
ret = Sm4CbcDecrypt(cipherText[0:ret],plainText,key,iv)
fmt.Println(string(plainText[0:ret]))
func Sm4CbcEncrypt(source,cipherText,key,iv []byte)(int){
clen := (C.int)(0)
C.Sm4CbcEncrypt((*C.uchar)(unsafe.Pointer(&source[0])),(C.int)(len(source)),
(*C.uchar)(unsafe.Pointer(&cipherText[0])),&clen,
(*C.uchar)(unsafe.Pointer(&key[0])),
(*C.uchar)(unsafe.Pointer(&iv[0])));
return int(clen)
}
func Sm4CbcDecrypt(source,plainText,key,iv []byte)(int){
clen := (C.int)(0)
C.Sm4CbcDecrypt((*C.uchar)(unsafe.Pointer(&source[0])),(C.int)(len(source)),
(*C.uchar)(unsafe.Pointer(&plainText[0])),&clen,
(*C.uchar)(unsafe.Pointer(&key[0])),
(*C.uchar)(unsafe.Pointer(&iv[0])));
return int(clen)
}