Documentation ¶
Index ¶
- Constants
- Variables
- func Adler32(b []byte) uint32
- func ComputeHMAC256(message string, secret string) string
- func ComputeHMAC512(message string, secret string) string
- func Crc32Castagnoli(b []byte) uint32
- func Crc32IEEE(b []byte) uint32
- func Crc32Koopman(b []byte) uint32
- func Crc64ECMA(b []byte) uint64
- func Crc64ISO(b []byte) uint64
- func DecryptAESGCM(cipherText []byte) ([]byte, error)
- func DecryptOAEP(cipher string, label string) (string, error)
- func EncryptAESGCM(secret []byte) ([]byte, error)
- func EncryptOAEP(secret string, label string) (string, error)
- func InitAES(key []byte) error
- func IsMatchedHMAC256(signature string, message string, secret string) bool
- func IsMatchedHMAC512(signature string, message string, secret string) bool
- func LoadPrivateKey(path string) error
- func LoadPublicKey(path string) error
- type MACAlgo
Constants ¶
const INVALID_AES_KEY_LENGTH = "invalid AES key length. Expected 32 bytes, got %d bytes"
Variables ¶
var AESSecretKey []byte
var AppPrivateKey *rsa.PrivateKey
var AppPublicKey *rsa.PublicKey
Functions ¶
func ComputeHMAC256 ¶
ComputeHMAC256 computes HMAC256 signature of the message using the given secret parameters: message string, secret string return: base64 encoded HMAC256 signature
func ComputeHMAC512 ¶
ComputeHMAC512 computes HMAC512 signature of the message using the given secret parameters: message string, secret string return: base64 encoded HMAC512 signature
func Crc32Castagnoli ¶ added in v1.0.5
func Crc32Koopman ¶ added in v1.0.5
func DecryptAESGCM ¶ added in v1.1.0
func DecryptOAEP ¶
Decrypt decrypts the given base64 encoded RSA-OAEP cipher text using the AppKey, SHA256 hash function
Returns the plain text string ¶
The label parameter must match the value given when encrypting
func EncryptAESGCM ¶ added in v1.1.0
func EncryptOAEP ¶
Encrypt encrypts the given secret string with RSA-OAEP using the AppKey, SHA256 hash function and specified label
Returns the base64 encoded cipher text
func IsMatchedHMAC256 ¶
IsMatchedHMAC256 compares HMAC256 signature between the given signature to the computed signature based on given message and secret parameters: signature string, message string, secret string return: true if matched, false otherwise
func IsMatchedHMAC512 ¶
IsMatchedHMAC512 compares HMAC512 signature between the given signature to the computed signature based on given message and secret parameters: signature string, message string, secret string return: true if matched, false otherwise
func LoadPrivateKey ¶
LoadPrivateKey loads the public key from the given PKCS8 PEM encoded key file
If the argument path is empty, the default app.key file on the same directory of executable is assumed to be used
func LoadPublicKey ¶
LoadPublicKey loads the public key from the given PEM certificate file
If the argument path is empty, the default app.crt file on the same directory of executable is assumed to be used