padding

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DePadding

func DePadding(data []byte, method PaddingType, blockSize int) ([]byte, error)

DePadding depads data with method provided such as Zero Padding.

func DePaddingISO97971

func DePaddingISO97971(data []byte) []byte

DePaddingISO97971 is similar with PKCS7, its block size is 8.

func DePaddingPKCS5

func DePaddingPKCS5(data []byte) []byte

DePaddingPKCS5 is similar with PKCS7, its block size is 8.

func DePaddingPKCS7

func DePaddingPKCS7(data []byte) []byte

DePaddingPKCS7 remove PKCS7 padding at the end of byte slice.

func DePaddingZero

func DePaddingZero(data []byte) []byte

DePaddingZero remove zero padding at the end of byte slice.

func Padding

func Padding(data []byte, method PaddingType, blockSize int) ([]byte, error)

Padding pads data with method provided such as Zero Padding.

func PaddingISO97971

func PaddingISO97971(data []byte, blockSize int) []byte

PaddingISO97971 add padding at the end of byte slice with zero bytes which are separated by 0x80.

func PaddingPKCS5

func PaddingPKCS5(data []byte) []byte

PaddingPKCS5 is similar with PKCS7, its block size is 8.

func PaddingPKCS7

func PaddingPKCS7(data []byte, blockSize int) []byte

PaddingPKCS7 add padding at the end of byte slice with PKCS7 bytes. PKCS7 padding is a generalization of PKCS5 padding (also known as standard padding). PKCS7 padding works by appending N bytes with the value of chr(N) , where N is the number of bytes required to make the final block of data the same size as the block size.

func PaddingZero

func PaddingZero(data []byte, blockSize int) []byte

PaddingZero add padding at the end of byte slice with byte 0.

Types

type PaddingType

type PaddingType uint8

PaddingType is the padding method such as PKCS7.

const (
	// ISO97971 add padding at the end of byte slice with zero bytes which are separated by 0x80.
	ISO97971 PaddingType = 1 + iota
	// No add no padding.
	No
	// PKCS5 is similar to PKCS7, but its block size is 8.
	PKCS5
	// PKCS7 padding is a generalization of PKCS5 padding (also known as standard padding). PKCS7 padding works by
	// appending N bytes with the value of chr(N) , where N is the number of bytes required to make the final block of
	// data the same size as the block size.
	PKCS7
	// Zero add padding at the end of byte slice with byte 0.
	Zero
)

Jump to

Keyboard shortcuts

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