symmetric

package
v0.0.1-beta.1 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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CryptoS

type CryptoS struct {
	// InputData is the data to be encrypted.
	InputData []byte

	// OutputData is the data encrypted.
	OutputData []byte

	// Key is the secret used for encrypted
	Key []byte

	// An initialization vector (IV) is an arbitrary number that can be used with a secret key for data encryption
	// to foil cyberattacks. This number, also called a nonce (number used once), is employed only one time in
	// any session to prevent unauthorized decryption of the message by a suspicious or malicious actor.
	IV []byte

	// Method is the encryption method such as AES.
	Method method.MethodType

	// Mode is the encrypted mode such as ECB.
	Mode mode.ModeType

	// Padding is the padding method such as PKCS7.
	Padding padding.PaddingType

	// Errors is the errors
	Errors error
}

CryptoS is the struct for symmetric-key algorithm.

func NewCryptoS

func NewCryptoS() CryptoS

func (*CryptoS) Decrypt

func (s *CryptoS) Decrypt() *CryptoS

func (*CryptoS) Encrypt

func (s *CryptoS) Encrypt() *CryptoS

func (*CryptoS) IVFromBase64String

func (s *CryptoS) IVFromBase64String(data string) *CryptoS

IVFromBase64String set IV data from base64 string.

func (*CryptoS) IVFromBytes

func (s *CryptoS) IVFromBytes(data []byte) *CryptoS

IVFromBytes set IV data from byte slice.

func (*CryptoS) IVFromHexString

func (s *CryptoS) IVFromHexString(data string) *CryptoS

IVFromHexString set IV data from hex string.

func (*CryptoS) IVFromString

func (s *CryptoS) IVFromString(data string) *CryptoS

IVFromString set IV data from string.

func (*CryptoS) InputFromBase64String

func (s *CryptoS) InputFromBase64String(data string) *CryptoS

InputFromBase64String set input data from base64 string.

func (*CryptoS) InputFromBytes

func (s *CryptoS) InputFromBytes(data []byte) *CryptoS

InputFromBytes set input data from byte slice.

func (*CryptoS) InputFromHexString

func (s *CryptoS) InputFromHexString(data string) *CryptoS

InputFromHexString set input data from hex string.

func (*CryptoS) InputFromString

func (s *CryptoS) InputFromString(data string) *CryptoS

InputFromString set input data from string.

func (*CryptoS) KeyFromBase64String

func (s *CryptoS) KeyFromBase64String(data string) *CryptoS

KeyFromBase64String set key data from base64 string.

func (*CryptoS) KeyFromBytes

func (s *CryptoS) KeyFromBytes(data []byte) *CryptoS

KeyFromBytes set key data from byte slice.

func (*CryptoS) KeyFromHexString

func (s *CryptoS) KeyFromHexString(data string) *CryptoS

KeyFromHexString set key data from hex string.

func (*CryptoS) KeyFromString

func (s *CryptoS) KeyFromString(data string) *CryptoS

KeyFromString set key data from string.

func (*CryptoS) NewCipher

func (s *CryptoS) NewCipher() (cipher.Block, error)

NewCipher returns a cipher block from the cryptos.

func (*CryptoS) Reset

func (s *CryptoS) Reset()

Reset set all data to default for CryptoS.

func (*CryptoS) ToBase64String

func (s *CryptoS) ToBase64String() (string, error)

ToBase64String output data with base64 string.

func (*CryptoS) ToBytes

func (s *CryptoS) ToBytes() ([]byte, error)

ToBytes output data with byte type.

func (*CryptoS) ToHexString

func (s *CryptoS) ToHexString() (string, error)

ToHexString output data with hex string.

func (*CryptoS) ToString

func (s *CryptoS) ToString() (string, error)

ToString output data with string type.

func (*CryptoS) Validate

func (s *CryptoS) Validate(blockSize int) error

Validate validates the CryptoS and returns error if it does not meet the requirements.

func (*CryptoS) WithIV

func (s *CryptoS) WithIV(data []byte) *CryptoS

WithIV set IV for CryptoS.

func (*CryptoS) WithKey

func (s *CryptoS) WithKey(data []byte) *CryptoS

WithKey set Key for CryptoS.

func (*CryptoS) WithMethod

func (s *CryptoS) WithMethod(method method.MethodType) *CryptoS

WithMethod set method for CryptoS.

func (*CryptoS) WithMode

func (s *CryptoS) WithMode(mode mode.ModeType) *CryptoS

WithMode set mode for CryptoS.

func (*CryptoS) WithPadding

func (s *CryptoS) WithPadding(padding padding.PaddingType) *CryptoS

WithPadding set padding for CryptoS.

Directories

Path Synopsis
sm4

Jump to

Keyboard shortcuts

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