encoder

package
v0.0.0-...-1147cba Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64StdDecode

func Base64StdDecode(s string) string

Base64StdDecode decode a base64 encoded string. Play: https://go.dev/play/p/RWQylnJVgIe

func Base64StdEncode

func Base64StdEncode(s string) string

Base64StdEncode encode string with base64 encoding. Play: https://go.dev/play/p/VOaUyQUreoK

func BasicDecodeFromJSON

func BasicDecodeFromJSON(jsonString string) (map[string]interface{}, error)

BasicDecodeFromJSON decodes JSON string to data

func BasicEncodeToJSON

func BasicEncodeToJSON(data interface{}) (string, error)

BasicEncodeToJSON encodes data to JSON string

func DecodeJSONWithKey

func DecodeJSONWithKey(encodedData string, key interface{}, v interface{}, encryptionType EncryptionType) error

DecodeJSONWithKey decodes the given string using the provided key, then decrypts it from JSON format, and returns the original data.

func Decrypt

func Decrypt(encodedData string, key interface{}, encryptionType EncryptionType) ([]byte, error)

Decrypt decrypts the given string using the provided key and encryption algorithm.

func EncodeJSONWithKey

func EncodeJSONWithKey(data interface{}, key interface{}, encryptionType EncryptionType) (string, error)

EncodeJSONWithKey encodes the given data in JSON format, then encrypts it using the provided key, and returns the encoded string.

func Encrypt

func Encrypt(data []byte, key interface{}, encryptionType EncryptionType) (string, error)

Encrypt encrypts the given data using the provided key and encryption algorithm.

func GenerateAESKey

func GenerateAESKey(keyLength int) (string, error)

GenerateAESKey generates a random AES key of the specified length

func GenerateDESKey

func GenerateDESKey() (string, error)

GenerateDESKey generates a random DES key of the specified length

func GenerateRSAKeyPair

func GenerateRSAKeyPair(keySize int) (*rsa.PrivateKey, error)

GenerateRSAKeyPair generates a new RSA key pair with the specified key size.

func ValidateAESKey

func ValidateAESKey(key string) bool

ValidateAESKey checks if the given key is a valid AES key

func ValidateDESKey

func ValidateDESKey(key string) bool

ValidateDESKey checks if the given key is a valid DES key

Types

type EncryptionType

type EncryptionType int

EncryptionType represents the type of encryption algorithm used

const (
	// AES is the type of encryption used
	AES EncryptionType = iota
	// RSA is another type of encryption
	RSA
	// DES is another type of encryption
	DES
)

Jump to

Keyboard shortcuts

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