utils

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressAndHash added in v0.3.2

func CompressAndHash(data []byte) (hash, encoded string, err error)

CompressAndHash compresses the data with Gzip, calculates the SHA256 hex hash of the compressed bytes, and then encodes the compressed bytes to Base64. This is a common requirement for SIAT file uploads.

func CreateTarGz added in v0.4.0

func CreateTarGz(files map[string][]byte) ([]byte, error)

CreateTarGz creates a TAR.GZ archive from a map of filenames and contents.

func Float64Ptr added in v0.5.0

func Float64Ptr(v float64) *float64

Float64Ptr returns a pointer to the given float64 value.

func GenerarCUF

func GenerarCUF(nit int64, fechaHora time.Time, sucursal, modalidad, tipoEmision, tipoFactura, tipoDocumentoSector, numeroFactura, puntoVenta int, codigoControl string) (string, error)

GenerarCUF genera el CUF completo para una factura

Args:

nit (int64): Nit del contribuyente.
fechaHora (time.Time): Fecha y hora de emisión de la factura.
sucursal (int): Número de sucursal.
modalidad (int): Modalidad de emisión.
tipoEmision (int): Tipo de emisión.
tipoFactura (int): Tipo de factura.
tipoDocumentoSector (int): Tipo de documento sector.
numeroFactura (int): Número de la factura.
puntoVenta (int): Punto de venta.
codigoControl (string): Código de control.

Returns:

(string, error): CUF completo y error si ocurre.

func Gzip added in v0.3.2

func Gzip(data []byte) ([]byte, error)

Gzip compress the provided data using Gzip.

func Int64Ptr added in v0.5.0

func Int64Ptr(v int64) *int64

Int64Ptr returns a pointer to the given int64 value.

func IntPtr added in v0.5.0

func IntPtr(v int) *int

IntPtr returns a pointer to the given int value.

func ParseInt64Safe

func ParseInt64Safe(valStr string) (int64, error)

ParseInt64Safe converts a string to int64 (ideal for NIT). Returns a descriptive error if the conversion fails.

func ParseIntSafe

func ParseIntSafe(valStr string) (int, error)

ParseIntSafe converts a string to int, removing whitespace. Returns a descriptive error if the conversion fails.

func SHA256Hex added in v0.3.2

func SHA256Hex(data []byte) string

SHA256Hex calculates the SHA-256 hash of the provided data and returns it as a hexadecimal encoded string.

func SHA512Hex added in v0.3.2

func SHA512Hex(data []byte) string

SHA512Hex calculates the SHA-512 hash of the provided data and returns it as a hexadecimal encoded string.

func SignWithP12 added in v0.3.4

func SignWithP12(xmlBytes []byte, p12Path, password string) ([]byte, error)

SignWithP12 acts as a bridge between the p12 file and the existing signing function

func SignWithP12Bytes added in v0.3.4

func SignWithP12Bytes(xmlBytes, p12Data []byte, password string) ([]byte, error)

SignWithP12Bytes signs an XML using the bytes of the p12 file Ideal for when the certificate comes from a DB or a Vault

func SignXML

func SignXML(xmlBytes []byte, keyPath, certPath string) ([]byte, error)

SignXML signs an XML document receiving certificates and key from files

func SignXMLBytes added in v0.3.2

func SignXMLBytes(xmlBytes, keyBytes, certBytes []byte) ([]byte, error)

SignXMLBytes signs an XML document receiving certificates and key directly in bytes

func VerifyCertificateValidity added in v0.3.4

func VerifyCertificateValidity(cert *x509.Certificate) error

VerifyCertificateValidity checks if the certificate is valid today

func VerifyP12Expiry added in v0.3.4

func VerifyP12Expiry(p12Data []byte, password string) error

VerifyP12Expiry checks the validity of the certificate within the P12 bytes

Types

This section is empty.

Jump to

Keyboard shortcuts

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