cipher

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PKCS7Padding

func PKCS7Padding(data []byte, blockSize int) ([]byte, error)

PKCS7Padding add the padding to the data before encrypting, to make the input a multiple of the AES block size.

func PKCS7UnPadding

func PKCS7UnPadding(plantText []byte) []byte

PKCS7UnPadding remove padding before decrypting

func RsaEncrypt

func RsaEncrypt(message []byte, keyFileName string) ([]byte, error)

RsaEncrypt encrypt given message with RAS public key file

Types

type AesCipher

type AesCipher interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(encrypted []byte) ([]byte, error)
	Key() []byte
	Iv() []byte
}

func AesWithRandomKey

func AesWithRandomKey(keySize int) (AesCipher, error)

AesWithRandomKey creates and initialize AES cipher with random key and iv. The keySize argument should be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256

func NewAes

func NewAes(key, iv []byte) (AesCipher, error)

NewAes creates and initialize AES cipher. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. The length of iv must be the same as the Block's block size (16 bytes).

Jump to

Keyboard shortcuts

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