Documentation
¶
Index ¶
- func CompressAndHash(data []byte) (hash, encoded string, err error)
- func CreateTarGz(files map[string][]byte) ([]byte, error)
- func Float64Ptr(v float64) *float64
- func GenerarCUF(nit int64, fechaHora time.Time, ...) (string, error)
- func Gzip(data []byte) ([]byte, error)
- func Int64Ptr(v int64) *int64
- func IntPtr(v int) *int
- func ParseInt64Safe(valStr string) (int64, error)
- func ParseIntSafe(valStr string) (int, error)
- func SHA256Hex(data []byte) string
- func SHA512Hex(data []byte) string
- func SignWithP12(xmlBytes []byte, p12Path, password string) ([]byte, error)
- func SignWithP12Bytes(xmlBytes, p12Data []byte, password string) ([]byte, error)
- func SignXML(xmlBytes []byte, keyPath, certPath string) ([]byte, error)
- func SignXMLBytes(xmlBytes, keyBytes, certBytes []byte) ([]byte, error)
- func VerifyCertificateValidity(cert *x509.Certificate) error
- func VerifyP12Expiry(p12Data []byte, password string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressAndHash ¶ added in v0.3.2
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
CreateTarGz creates a TAR.GZ archive from a map of filenames and contents.
func Float64Ptr ¶ added in v0.5.0
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 ParseInt64Safe ¶
ParseInt64Safe converts a string to int64 (ideal for NIT). Returns a descriptive error if the conversion fails.
func ParseIntSafe ¶
ParseIntSafe converts a string to int, removing whitespace. Returns a descriptive error if the conversion fails.
func SHA256Hex ¶ added in v0.3.2
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
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
SignWithP12 acts as a bridge between the p12 file and the existing signing function
func SignWithP12Bytes ¶ added in v0.3.4
SignWithP12Bytes signs an XML using the bytes of the p12 file Ideal for when the certificate comes from a DB or a Vault
func SignXMLBytes ¶ added in v0.3.2
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
VerifyP12Expiry checks the validity of the certificate within the P12 bytes
Types ¶
This section is empty.