crypto

package
v0.0.0-...-be61b1a Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptVerifyToken

func DecryptVerifyToken(encodedCiphertext, keyHex string) (string, error)

func DecryptWithKey

func DecryptWithKey(ciphertext, key, iv []byte) (string, error)

DecryptWithKey decrypts ciphertext using a provided key and IV.

func EncryptWithKey

func EncryptWithKey(plaintext string, key []byte) ([]byte, []byte, error)

EncryptWithKey encrypts plaintext using the provided encryption key and returns the ciphertext and IV. It uses AES-GCM mode for encryption.

func GenerateDataKeyAWS

func GenerateDataKeyAWS(kmsClient *kms.KMS, keySpec string) (*kms.GenerateDataKeyOutput, error)

Parameters - keySpec (string): Specify the desired key specification, eg "AES_256" - kmsClient refers to an instance of the AWS Key Management Service (KMS) client

func GenerateIV

func GenerateIV(size int) ([]byte, error)

GenerateIV generates a random Initialization Vector (IV) with the specified size.

func GenerateVerifyToken

func GenerateVerifyToken(keyHex string) (string, string, error)

func Hash

func Hash(password string) (string, error)

func InitializeAWSSessionAndKMSClientAWS

func InitializeAWSSessionAndKMSClientAWS() (*session.Session, *kms.KMS)

InitializeAWSSessionAndKMSClient initializes an AWS session and a KMS client.

func IsHashValid

func IsHashValid(password, hash string) bool

func RetrieveEncryptionKeyAWS

func RetrieveEncryptionKeyAWS(keyID string) ([]byte, error)

RetrieveEncryptionKey retrieves the encryption key from AWS Key Management Service (KMS) using the specified key ID.

Types

type AllowedByteSize

type AllowedByteSize int
const (
	ByteSize18  AllowedByteSize = 18
	ByteSize32  AllowedByteSize = 32
	ByteSize64  AllowedByteSize = 64
	ByteSize128 AllowedByteSize = 128
	ByteSize256 AllowedByteSize = 256
)

func (AllowedByteSize) GenerateKey

func (bs AllowedByteSize) GenerateKey() (string, error)

GenerateKey generates a key with the specified byte size

Jump to

Keyboard shortcuts

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