libs

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 0 Imported by: 0

README

go-libs

Shared internal helpers used across go-* libraries and application modules.

Install

go get github.com/andywang2011/go-libs@v0.1.0

Quick start

digest := hash.SHA256Hex("hello")
fmt.Println(digest)

svc, _ := encrypt.NewEncryptServiceFromConfig(encrypt.EncryptConfig{Key: key32}) // 32-byte AES-256 key
ct, _ := svc.Encrypt("secret")                                                    // base64(nonce||ciphertext||tag)

Examples

  • cryptox/aesx — AES-GCM (preferred) and AES-CBC with explicit IV
  • cryptox/rsax — RSA PKCS#1 / PKCS#8
  • cryptox/pgp — signed OpenPGP encrypt / verified decrypt (ProtonMail go-crypto)
  • random — CSPRNG helpers (UUID, UUIDWithLen, MustToken, NumCode)
  • types — generic Set and slice/map utilities
  • timex — JSON/database time type
  • jsonmap — GORM JSON map column type
  • reflectx — struct-to-map reflection (honours json:"name,omitempty")
  • hash — SHA-256 and HMAC-SHA256
  • encrypt — AES-256-GCM encrypt service (DI-friendly)
cd go-libs/examples/sha256 && go run .

License

MIT — see LICENSE.

Documentation

Overview

Package libs is reserved for shared internal helpers used across go-* modules.

Design constraints:

  • Pure helpers only: no viper, no log.Fatal, no process lifecycle.
  • No global mutable state; callers pass inputs and own side effects.
  • Prefer dedicated go-* SDK modules for network clients and IO boundaries.
  • ConfigDefault: N/A — pure helper packages with no shared Config struct.

Crypto policy: only authenticated or modern primitives are exposed. AES-GCM (cryptox/aesx, encrypt), SHA-256/HMAC (hash), CSPRNG-backed tokens (random), and signed OpenPGP (cryptox/pgp). ECB, DES, MD5, and math/rand-based token helpers were removed.

This module intentionally stays minimal. Prefer dedicated go-* packages for production-ready clients (redis, mongo, httplib, etc.) rather than growing this umbrella module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Doc

func Doc() string

Doc returns a short package description for tests and documentation.

Types

This section is empty.

Directories

Path Synopsis
cryptox
aesx
Package aesx provides AES helpers: AES-GCM (preferred) and AES-CBC with an explicit IV.
Package aesx provides AES helpers: AES-GCM (preferred) and AES-CBC with an explicit IV.
pgp
Package pgp provides signed OpenPGP encryption and verified decryption helpers built on github.com/ProtonMail/go-crypto/openpgp.
Package pgp provides signed OpenPGP encryption and verified decryption helpers built on github.com/ProtonMail/go-crypto/openpgp.
Package encrypt provides a DI-friendly AES-256-GCM string encryption service.
Package encrypt provides a DI-friendly AES-256-GCM string encryption service.
Package hash provides SHA-256 and HMAC-SHA256 helpers.
Package hash provides SHA-256 and HMAC-SHA256 helpers.
Package random provides cryptographically secure random helpers.
Package random provides cryptographically secure random helpers.
Package reflectx provides small reflection helpers.
Package reflectx provides small reflection helpers.

Jump to

Keyboard shortcuts

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