cryption

package
v0.0.0-...-f2a0a00 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64URLDecode

func Base64URLDecode(input string) (string, error)

Base64URLDecode decodes the given URL-safe string using base64 and returns the result as a string

func Base64URLEncode

func Base64URLEncode(input string) string

Base64URLEncode encodes the given string using base64 and returns the result as a URL-safe string

func Decrypt

func Decrypt(base64Ciphertext, base64Key string) (string, error)

Decrypt decrypts the given base64 encoded ciphertext using AES-GCM with the provided base64 encoded key and returns the plaintext

func DeriveKeyFromPassword

func DeriveKeyFromPassword(password string, salt string) string

DeriveKeyFromPassword generates an encryption key from a password using Argon2 and a provided salt

func Encrypt

func Encrypt(plaintext, base64Key string) (string, error)

Encrypt encrypts the given plaintext using AES-GCM with the provided base64 encoded key and returns the ciphertext as a base64 encoded string

func GenerateKey

func GenerateKey() (string, error)

GenerateKey generates a new AES key and returns it as a base64 encoded string

func GetJWTTokenExpirationUnix

func GetJWTTokenExpirationUnix(token string) (*float64, error)

it took me an embarrising long time to learn that the jwt tokens encode the expiration time inside of them

Types

type PasswordData

type PasswordData struct {
	Hash string
	Salt string
}

func GeneratePasswordHash

func GeneratePasswordHash(password string) (*PasswordData, error)

GeneratePasswordHash generates a secure hash of the password using bcrypt, returns hash and salt

Jump to

Keyboard shortcuts

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