cipher

package
v0.0.0-...-daff614 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64

func Base64(key []byte) string

func Encrypt

func Encrypt(symmetricKey []byte, msg string) string

Encrypt performs AES-GCM encryption on the input message using the provided symmetric key. It returns the base64-encoded ciphertext which includes the nonce. If encryption fails, it returns the original message unchanged.

func LoadPrivateKey

func LoadPrivateKey(path string) (ed25519.PrivateKey, error)

LoadPrivateKey loads an Ed25519 private key from the specified PEM file path. If path is empty, it generates a new Ed25519 key pair and returns the private key. It returns the private key and any error encountered.

func LoadSymmetricKey

func LoadSymmetricKey(path string) ([]byte, error)

LoadSymmetricKey loads a 32-byte symmetric key from the specified file path. If path is empty, it generates a new random key. The key file content can be either raw bytes or base64 encoded. It returns the key and any error encountered.

func PemKey

func PemKey(privateKey ed25519.PrivateKey) (string, error)

PemKey converts an Ed25519 private key to PEM-encoded PKCS#8 format. It returns the PEM-encoded key string and any error encountered.

Types

This section is empty.

Jump to

Keyboard shortcuts

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