api

package
v0.0.0-...-b1eacc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sm4CBCDecrypt

func Sm4CBCDecrypt(key, iv, cipherText []byte) ([]byte, error)

func Sm4CBCEncrypt

func Sm4CBCEncrypt(key, iv, plainText []byte) ([]byte, error)

func Sm4ECBDecrypt

func Sm4ECBDecrypt(key, cipherText []byte) ([]byte, error)
Example
cipher, err := hex.DecodeString(cipherPreset)
if err != nil {
	fmt.Println(err)
}

key, err := hex.DecodeString(keyPreset)
if err != nil {
	fmt.Println(err)
}

plain, err := Sm4ECBDecrypt(key, cipher)
if err != nil {
	fmt.Println(err)
}
fmt.Printf("%x", plain)
Output:

0123456789abcdeffedcba9876543210

func Sm4ECBEncrypt

func Sm4ECBEncrypt(key, plainText []byte) ([]byte, error)
Example
plain, err := hex.DecodeString(plainPreset)
if err != nil {
	fmt.Println(err)
}

key, err := hex.DecodeString(keyPreset)
if err != nil {
	fmt.Println(err)
}

cipher, err := Sm4ECBEncrypt(key, plain)
if err != nil {
	fmt.Println(err)
}
fmt.Printf("%x", cipher)
Output:

681edf34d206965e86b3e94f536e4246002a8a4efa863ccad024ac0300bb40d2

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL