crypto

package
v0.0.0-...-fee78ac Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEY_SIZE    = 512
	ERR_NO_INIT = "rsa crypto not initialized"
)

Variables

This section is empty.

Functions

func AESEncrypt

func AESEncrypt(raw []byte, key []byte, iv []byte) (string, error)

func AesDecryptAndReturnBytes

func AesDecryptAndReturnBytes(raw string, key []byte, iv []byte) ([]byte, error)

func GetAesKeySize

func GetAesKeySize() int

func GetSm4KeySize

func GetSm4KeySize() int

func RSAEncrypt

func RSAEncrypt(raw []byte, pk string) (string, error)

func SetAesKeySize

func SetAesKeySize(size int)

func SetSm4KeySize

func SetSm4KeySize(size int)

func Sm4DecryptAndReturnBytes

func Sm4DecryptAndReturnBytes(ciphertext string, key []byte, iv []byte) ([]byte, error)

func Sm4Encrypt

func Sm4Encrypt(plaintext []byte, key []byte, iv []byte) (string, error)

Types

type RSACrypto

type RSACrypto struct {
	// contains filtered or unexported fields
}

func NewRSACrypto

func NewRSACrypto() (*RSACrypto, error)

func NewRSACryptoFromKey

func NewRSACryptoFromKey(privateKey string) (*RSACrypto, error)

func (*RSACrypto) Decrypt

func (r *RSACrypto) Decrypt(raw string) (string, error)

func (*RSACrypto) DecryptAndReturnBytes

func (r *RSACrypto) DecryptAndReturnBytes(raw string) ([]byte, error)

func (*RSACrypto) Encrypt

func (r *RSACrypto) Encrypt(raw string) (string, error)

func (*RSACrypto) Private

func (r *RSACrypto) Private() string

func (*RSACrypto) Public

func (r *RSACrypto) Public() string

func (*RSACrypto) TryDecrypt

func (r *RSACrypto) TryDecrypt(raw string) string

func (*RSACrypto) TryEncrypt

func (r *RSACrypto) TryEncrypt(raw string) string

Jump to

Keyboard shortcuts

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