crypto

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package crypto provides field-level encryption for Geode node and edge properties. It uses AES-256-GCM for authenticated encryption with HKDF-SHA256 for key derivation and HMAC-SHA256 for deterministic searchable encryption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

Cipher holds derived encryption and HMAC keys for field-level encryption.

func NewCipher

func NewCipher(masterKey []byte) (*Cipher, error)

NewCipher creates a new Cipher from the given master key. masterKey must be at least 32 bytes.

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts a ciphertext produced by Encrypt. Returns an error if the input is too short or authentication fails.

func (*Cipher) DecryptString

func (c *Cipher) DecryptString(encoded string) (string, error)

DecryptString base64-decodes the input and decrypts it, returning the original string.

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(plaintext []byte) ([]byte, error)

Encrypt encrypts plaintext using AES-256-GCM with a random nonce. The returned ciphertext has the nonce prepended.

func (*Cipher) EncryptString

func (c *Cipher) EncryptString(plaintext string) (string, error)

EncryptString encrypts the plaintext string and returns a base64-encoded result.

func (*Cipher) HMACHex

func (c *Cipher) HMACHex(input string) string

HMACHex computes an HMAC-SHA256 of input using the derived HMAC key and returns the result as a lowercase hex string. The output is deterministic — the same input always produces the same output.

Jump to

Keyboard shortcuts

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