Documentation
¶
Index ¶
- func Base64StdDecode(s string) string
- func Base64StdEncode(s string) string
- func BasicDecodeFromJSON(jsonString string) (map[string]interface{}, error)
- func BasicEncodeToJSON(data interface{}) (string, error)
- func DecodeJSONWithKey(encodedData string, key interface{}, v interface{}, ...) error
- func Decrypt(encodedData string, key interface{}, encryptionType EncryptionType) ([]byte, error)
- func EncodeJSONWithKey(data interface{}, key interface{}, encryptionType EncryptionType) (string, error)
- func Encrypt(data []byte, key interface{}, encryptionType EncryptionType) (string, error)
- func GenerateAESKey(keyLength int) (string, error)
- func GenerateDESKey() (string, error)
- func GenerateRSAKeyPair(keySize int) (*rsa.PrivateKey, error)
- func ValidateAESKey(key string) bool
- func ValidateDESKey(key string) bool
- type EncryptionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64StdDecode ¶
Base64StdDecode decode a base64 encoded string. Play: https://go.dev/play/p/RWQylnJVgIe
func Base64StdEncode ¶
Base64StdEncode encode string with base64 encoding. Play: https://go.dev/play/p/VOaUyQUreoK
func BasicDecodeFromJSON ¶
BasicDecodeFromJSON decodes JSON string to data
func BasicEncodeToJSON ¶
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 ¶
GenerateAESKey generates a random AES key of the specified length
func GenerateDESKey ¶
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 ¶
ValidateAESKey checks if the given key is a valid AES key
func ValidateDESKey ¶
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 )