package generadorFirmaDigital

import (
	"bytes"
	"compress/gzip"
	"encoding/base64"
)

// -----------------------------------------------------
// comprime GZIP y codifica Base64.
// -----------------------------------------------------
func GzipBase64(data []byte) (string, error) {
	var buf bytes.Buffer
	gz := gzip.NewWriter(&buf)
	if _, err := gz.Write(data); err != nil {
		return "", err
	}
	if err := gz.Close(); err != nil {
		return "", err
	}
	return base64.StdEncoding.EncodeToString(buf.Bytes()), nil
}
