sm4

package
v0.0.0-...-45efea6 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockSize = 16
	KeySize   = 16
)

Variables

This section is empty.

Functions

func CBCDecrypt

func CBCDecrypt(key, iv, cipherText []byte) (plainText []byte, err error)

输出的plainText是加padding的明文,调用方需要自己去padding, 可调用util.PKCS5UnPadding()方法进行去padding操作

func CBCEncrypt

func CBCEncrypt(key, iv, plainText []byte) (cipherText []byte, err error)

输入的plainText长度必须是BlockSize(16)的整数倍,也就是调用该方法前调用方需先加好padding, 可调用util.PKCS5Padding()方法进行加padding操作

func ECBDecrypt

func ECBDecrypt(key, cipherText []byte) (plainText []byte, err error)

输出的plainText是加padding的明文,调用方需要自己去padding, 可调用util.PKCS5UnPadding()方法进行去padding操作

func ECBEncrypt

func ECBEncrypt(key, plainText []byte) (cipherText []byte, err error)

输入的plainText长度必须是BlockSize(16)的整数倍,也就是调用该方法前调用方需先加好padding, 可调用util.PKCS5Padding()方法进行加padding操作

func NewCipher

func NewCipher(key []byte) (cipher.Block, error)

Types

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

Jump to

Keyboard shortcuts

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