encryptedtypeent

package module
v0.0.0-...-5968d20 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

encryptedtype-ent

Ent field helper for github.com/ubgo/encryptedtype.

Returns a TEXT column tagged Sensitive() so ent's debug output never prints the AES-GCM ciphertext.

Install

go get github.com/ubgo/encryptedtype-ent

Boot wiring (required)

Before any Value/Scan happens, configure the AES key once at process startup:

import "github.com/ubgo/encryptedtype"

func main() {
    if err := encryptedtype.SetKey([]byte(os.Getenv("ENCRYPTION_KEY"))); err != nil {
        log.Fatal(err)
    }
    // ... start server
}

Use

import (
    "entgo.io/ent"

    encryptedtypeent "github.com/ubgo/encryptedtype-ent"
)

type Partner struct{ ent.Schema }

func (Partner) Fields() []ent.Field {
    return []ent.Field{
        encryptedtypeent.Field("api_secret"),
    }
}

For finer control compose directly:

field.String("api_secret").
    GoType(encryptedtype.EncryptedString{}).
    Sensitive().
    Optional()

License

Apache-2.0 — see LICENSE.

Documentation

Overview

Package encryptedtypeent provides an ent.Field constructor for github.com/ubgo/encryptedtype.EncryptedString columns.

IMPORTANT: callers must wire the encryption key at process boot via encryptedtype.SetKey before any Value/Scan happens. See the encryptedtype README.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Field

func Field(name string) ent.Field

Field returns an ent.Field for an EncryptedString column.

  • Stored as TEXT (the AES-GCM ciphertext is base64url-encoded and longer than the plaintext).
  • Sensitive() set so the value is masked in ent's debug/print output.

For Optional, Immutable, dialect-specific column type, etc., compose directly:

field.String("api_secret").
    GoType(encryptedtype.EncryptedString{}).
    Sensitive().
    Optional()

Types

This section is empty.

Jump to

Keyboard shortcuts

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