crypts

package
v0.0.0-...-8b25bc4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenRSAKey

func GenRSAKey(out io.Writer, bits int) error

func NewNonce

func NewNonce(size int) []byte

Types

type AESCrypt

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

func NewAESCrypt

func NewAESCrypt(opts ...OptFunc) (*AESCrypt, error)

func (*AESCrypt) Decode2Byte

func (c *AESCrypt) Decode2Byte(s string) ([]byte, error)

func (*AESCrypt) Decrypt

func (c *AESCrypt) Decrypt(ciphertext string) (string, error)

func (*AESCrypt) Decrypt2Byte

func (c *AESCrypt) Decrypt2Byte(ciphertext string) ([]byte, error)

func (*AESCrypt) Encode2Str

func (c *AESCrypt) Encode2Str(b []byte) string

func (*AESCrypt) Encrypt

func (c *AESCrypt) Encrypt(plaintext string) (string, error)

func (*AESCrypt) Encrypt4Byte

func (c *AESCrypt) Encrypt4Byte(plaintext []byte) (string, error)

func (*AESCrypt) NewNonce

func (c *AESCrypt) NewNonce() []byte

func (*AESCrypt) NewNonceStr

func (c *AESCrypt) NewNonceStr() string

type OptFunc

type OptFunc func(c *AESCrypt)

func OptWithDataByte

func OptWithDataByte(data []byte) OptFunc

func OptWithIStr

func OptWithIStr(istr stringer) OptFunc

func OptWithKeyByte

func OptWithKeyByte(key []byte) OptFunc

func OptWithNonceByte

func OptWithNonceByte(nonce []byte) OptFunc

type RsaCrypt

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

func NewRSA

func NewRSA() *RsaCrypt

func (*RsaCrypt) Decrypt

func (r *RsaCrypt) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts data with private key

func (*RsaCrypt) DecryptPKCS1v15

func (r *RsaCrypt) DecryptPKCS1v15(ciphertext []byte) ([]byte, error)

DecryptPKCS1v15 decrypts data with private key

func (*RsaCrypt) DecryptToString

func (r *RsaCrypt) DecryptToString(ciphertext string) (string, error)

func (*RsaCrypt) DecryptToStringByHex

func (r *RsaCrypt) DecryptToStringByHex(ciphertext string) (string, error)

func (*RsaCrypt) Encrypt

func (r *RsaCrypt) Encrypt(msg []byte) ([]byte, error)

Encrypt encrypts data with public key

func (*RsaCrypt) EncryptPKCS1v15

func (r *RsaCrypt) EncryptPKCS1v15(msg []byte) ([]byte, error)

EncryptPKCS1v15 encrypts data with public key

func (*RsaCrypt) EncryptToString

func (r *RsaCrypt) EncryptToString(plaintext string) (string, error)

func (*RsaCrypt) EncryptToStringByHex

func (r *RsaCrypt) EncryptToStringByHex(plaintext string) (string, error)

func (*RsaCrypt) SetPrivateKey

func (r *RsaCrypt) SetPrivateKey(private []byte) error

SetPrivateKey bytes to private key

func (*RsaCrypt) SetPrivateKeyByBase64Str

func (r *RsaCrypt) SetPrivateKeyByBase64Str(privateStr string) error

SetPrivateKeyByBase64Str Get bytes data by decoding base64 string

func (*RsaCrypt) SetPublicKey

func (r *RsaCrypt) SetPublicKey(public []byte) error

SetPublicKey bytes to public key

func (*RsaCrypt) SetPublicKeyByBase64Str

func (r *RsaCrypt) SetPublicKeyByBase64Str(publicStr string) error

SetPublicKeyByBase64Str Get bytes data by decoding base64 string

Jump to

Keyboard shortcuts

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