crypto

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package crypto contains functions to help perform hashing and simple encryption operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Curves

func Curves(c string) (elliptic.Curve, bool)

Curves -

func DecryptAESCBC

func DecryptAESCBC(key []byte, in []byte) ([]byte, error)

DecryptAESCBC - use a 128, 192, or 256 bit key to decrypt the given content using AES-CBC. The output will not be encoded. Empty content will not be decrypted.

This function is compatible with Helm's encryptAES function, when the input is base64-decoded, and when the key is 256 bits long.

func ECDSADerivePublicKey

func ECDSADerivePublicKey(privatekey []byte) ([]byte, error)

ECDSADerivePublicKey -

func ECDSAGenerateKey

func ECDSAGenerateKey(curve elliptic.Curve) ([]byte, error)

ECDSAGenerateKey -

func Ed25519DerivePublicKey

func Ed25519DerivePublicKey(privatekey []byte) ([]byte, error)

Ed25519DerivePublicKey returns an ed25519 Public Key from given PEM encoded `privatekey`.

func Ed25519GenerateKey

func Ed25519GenerateKey() ([]byte, error)

Ed25519GenerateKey returns a random PEM encoded Ed25519 Private Key.

func Ed25519GenerateKeyFromSeed

func Ed25519GenerateKeyFromSeed(seed []byte) ([]byte, error)

Ed25519GenerateKeyFromSeed returns a PEM encoded Ed25519 Private Key from `seed`. Returns error if len(seed) is not ed25519.SeedSize (32).

func EncryptAESCBC

func EncryptAESCBC(key []byte, in []byte) ([]byte, error)

EncryptAESCBC - use a 128, 192, or 256 bit key to encrypt the given content using AES-CBC. The output will not be encoded. Usually the output would be base64-encoded for display. Empty content will not be encrypted.

This function is compatible with Helm's decryptAES function, when the output is base64-encoded, and when the key is 256 bits long.

func PBKDF2

func PBKDF2(password, salt []byte, iter, keylen int, hashFunc crypto.Hash) ([]byte, error)

PBKDF2 - Run the Password-Based Key Derivation Function #2 as defined in RFC 8018 (PKCS #5 v2.1)

func RSADecrypt

func RSADecrypt(key string, in []byte) ([]byte, error)

RSADecrypt - decrypt the ciphertext with the given private key. The key must be a PEM-encoded RSA private key in PKCS#1, ASN.1 DER form, typically beginning with "RSA PRIVATE KEY". The input text must be plain ciphertext, not base64-encoded.

func RSADerivePublicKey

func RSADerivePublicKey(privateKey []byte) ([]byte, error)

RSADerivePublicKey -

func RSAEncrypt

func RSAEncrypt(key string, in []byte) ([]byte, error)

RSAEncrypt - use the given public key to encrypt the given plaintext. The key should be a PEM-encoded RSA public key in PKIX, ASN.1 DER form, typically beginning with "PUBLIC KEY". PKCS#1 format is also supported as a fallback. The output will not be encoded, so consider base64-encoding it for display.

func RSAGenerateKey

func RSAGenerateKey(bits int) ([]byte, error)

RSAGenerateKey -

func StrToHash

func StrToHash(hash string) (crypto.Hash, error)

StrToHash - find a hash given a certain string

Types

This section is empty.

Jump to

Keyboard shortcuts

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