key

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(str string) string

Base64Decode decodes a base64 encoded string

func Base64Encode

func Base64Encode(str string) string

func Decrypt

func Decrypt(encryptedMessage string, sk string) string

func DecryptByte

func DecryptByte(encryptedMessage []byte, sk []byte) string

func Encrypt

func Encrypt(message string, ak string) string

func EncryptByte

func EncryptByte(message []byte, ak []byte) []byte

func GenerateKeyPair

func GenerateKeyPair() (public_key, private_key string)

func GenerateKeyPairByte

func GenerateKeyPairByte() ([]byte, []byte)

func GetPrivateKey

func GetPrivateKey() []byte

生成密钥

func New

func New(key []byte) (cipher.Block, error)

New returns a cipher.Block implementing RC5-32/12/16. The key argument must be 16 bytes.

func PrivateDecryptByte

func PrivateDecryptByte(key []byte, ciphertext []byte) ([]byte, error)

解密

func PrivateEncryByte

func PrivateEncryByte(key []byte, plaintext []byte) ([]byte, error)

加密

Types

type Key

type Key interface {
	DecryptByte([]byte) ([]byte, error)
	EncryptByte([]byte) ([]byte, error)

	DecryptString(string) (string, error)
	EncryptString(string) (string, error)
}

type KeyPair

type KeyPair struct {
	PublicKey  string
	PrivateKey string
}

func NewKeyPair

func NewKeyPair() *KeyPair

func (*KeyPair) DecryptString

func (k *KeyPair) DecryptString(encryptedMessage string) string

func (*KeyPair) EncryptByte

func (k *KeyPair) EncryptByte(message []byte) []byte

func (*KeyPair) EncryptString

func (k *KeyPair) EncryptString(message string) string

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

type PrivateKey

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

func NewPrivateKey

func NewPrivateKey() *PrivateKey

func (*PrivateKey) DecryptByte

func (p *PrivateKey) DecryptByte(ciphertext []byte) ([]byte, error)

func (*PrivateKey) DecryptString

func (p *PrivateKey) DecryptString(ciphertext string) (string, error)

func (*PrivateKey) EncryptByte

func (p *PrivateKey) EncryptByte(plaintext []byte) ([]byte, error)

func (*PrivateKey) EncryptString

func (p *PrivateKey) EncryptString(plaintext string) (string, error)

Jump to

Keyboard shortcuts

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