crypto

package
v0.0.0-...-82f6397 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsECDSAStr

func AsECDSAStr(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) (string, string, error)

AsECDSAStr returns private, public key string or error

func AsRSAStr

func AsRSAStr(privateKey *rsa.PrivateKey, publickKey *rsa.PublicKey) (string, string, error)

AsRSAStr returns private, public key string or error

func DecryptAES

func DecryptAES(text string) (string, error)

DecryptAES method is to extract back the encrypted text

func DecryptAESEnv

func DecryptAESEnv(ciphertext []byte) ([]byte, error)

DecryptAES decrypts data using AES algorithm Kept for the backward compatibility of env data decryption

func DecryptB64

func DecryptB64(s string) (string, error)

DecryptB64 decrypts from base64 string to readable string

func DecryptRSA

func DecryptRSA(cipherText string, privateKey rsa.PrivateKey) (string, error)

func EncryptAES

func EncryptAES(text string) (string, error)

EncryptAES method is to encrypt or hide any classified text

func EncryptAESEnv

func EncryptAESEnv(text []byte) ([]byte, error)

EncryptAESEnv encrypts data using AES algorithm kept for the backward compatibility of env data encryption

func EncryptB64

func EncryptB64(text string) string

EncryptB64 encrypts data into base64 string

func EncryptEnvData

func EncryptEnvData(data map[string]interface{}) (string, error)

EncryptEnvData is used to encrypt the env data

func EncryptPassword

func EncryptPassword(password string) (string, error)

EncryptPassword is used for encrypting password

func EncryptRSA

func EncryptRSA(message string, key rsa.PublicKey) (string, error)

func ExportEcdsaPrivateKeyAsPemStr

func ExportEcdsaPrivateKeyAsPemStr(privkey *ecdsa.PrivateKey) (string, error)

ExportEcdsaPrivateKeyAsPemStr to get ECDSA private key as pem string

func ExportEcdsaPublicKeyAsPemStr

func ExportEcdsaPublicKeyAsPemStr(pubkey *ecdsa.PublicKey) (string, error)

ExportEcdsaPublicKeyAsPemStr to get ECDSA public key as pem string

func ExportRsaPrivateKeyAsPemStr

func ExportRsaPrivateKeyAsPemStr(privkey *rsa.PrivateKey) string

ExportRsaPrivateKeyAsPemStr to get RSA private key as pem string

func ExportRsaPublicKeyAsPemStr

func ExportRsaPublicKeyAsPemStr(pubkey *rsa.PublicKey) string

ExportRsaPublicKeyAsPemStr to get RSA public key as pem string

func GenerateJWKBasedOnEnv

func GenerateJWKBasedOnEnv() (string, error)

GenerateJWKBasedOnEnv generates JWK based on env make sure clientID, jwtType, jwtSecret / public & private key pair is set this is called while initializing app / when env is updated

func GetPubJWK

func GetPubJWK(algo, keyID string, publicKey interface{}) (string, error)

GetPubJWK returns JWK for given keys

func IsECDSA

func IsECDSA(algo string) bool

IsECDSA checks if given string is valid ECDSA algo

func IsHMACA

func IsHMACA(algo string) bool

IsHMACValid checks if given string is valid HMCA algo

func IsRSA

func IsRSA(algo string) bool

IsRSA checks if given string is valid RSA algo

func NewECDSAKey

func NewECDSAKey(algo, keyID string) (*ecdsa.PrivateKey, string, string, string, error)

NewECDSAKey to generate new ECDSA Key if env is not set returns key instance, private key string, public key string, jwk string, error

func NewHMACKey

func NewHMACKey(algo, keyID string) (string, string, error)

NewHMAC key returns new key that can be used to ecnrypt data using HMAC algo returns key, string, error

func NewRSAKey

func NewRSAKey(algo, keyID string) (*rsa.PrivateKey, string, string, string, error)

NewRSAKey to generate new RSA Key if env is not set returns key instance, private key string, public key string, jwk string, error

func ParseEcdsaPrivateKeyFromPemStr

func ParseEcdsaPrivateKeyFromPemStr(privPEM string) (*ecdsa.PrivateKey, error)

ParseEcdsaPrivateKeyFromPemStr to parse ECDSA private key from pem string

func ParseEcdsaPublicKeyFromPemStr

func ParseEcdsaPublicKeyFromPemStr(pubPEM string) (*ecdsa.PublicKey, error)

ParseEcdsaPublicKeyFromPemStr to parse ECDSA public key from pem string

func ParseRsaPrivateKeyFromPemStr

func ParseRsaPrivateKeyFromPemStr(privPEM string) (*rsa.PrivateKey, error)

ParseRsaPrivateKeyFromPemStr to parse RSA private key from pem string

func ParseRsaPublicKeyFromPemStr

func ParseRsaPublicKeyFromPemStr(pubPEM string) (*rsa.PublicKey, error)

ParseRsaPublicKeyFromPemStr to parse RSA public key from pem string

Types

This section is empty.

Jump to

Keyboard shortcuts

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