Documentation
¶
Index ¶
- Variables
- func AesKeyGenerate() []byte
- type CompressFunc
- type CompressionType
- func AesDecrypt(ctx context.Context, algorithm CompressionType, body []byte, decryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
- func AesEncrypt(ctx context.Context, algorithm CompressionType, body []byte, encryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
- func GZipCompress(ctx context.Context, level int, algorithm CompressionType, body []byte, ...) (algorithmUsed CompressionType, result []byte, err *mft.Error)
- func GZipRestore(ctx context.Context, algorithm CompressionType, body []byte, decryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
- type Generator
- func (g *Generator) Add(name CompressionType, compressor CompressFunc, restore RestoreFunc)
- func (g *Generator) Compress(ctx context.Context, must bool, algorithm CompressionType, body []byte, ...) (algorithmUsed CompressionType, result []byte, err *mft.Error)
- func (g *Generator) Init()
- func (g *Generator) Restore(ctx context.Context, algorithm CompressionType, body []byte, decryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
- type RestoreFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var Errors map[int]string = map[int]string{
10200000: "Generator.Compress: algorithm %v is not exists and encrypt key is not null",
10200001: "Generator.Restore: algorithm %v is not exists",
10201000: "GZipRestore: gzip reader not created with error",
10201001: "GZipRestore: read gzip error",
10201002: "GZipRestore: readresult is large",
10201003: "GZipRestore: close gzip error",
10201100: "GZipCompress: gzip writer fail on create",
10201101: "GZipCompress: gzip writer fail on write",
10201102: "GZipCompress: gzip writer fail on close",
10202000: "AesEncrypt: input key len %v != 32",
10202001: "AesEncrypt: NewCipher fail",
10202002: "AesEncrypt: NewGCM fail",
10202003: "AesEncrypt: nonce fill fail",
10202100: "AesDecrypt: input key len %v != 32",
10202101: "AesDecrypt: NewCipher fail",
10202102: "AesDecrypt: NewGCM fail",
10202103: "AesDecrypt: decrypt fail",
}
Errors codes and description
View Source
var LimitZipRestore int64 = 1e8
Functions ¶
func AesKeyGenerate ¶
func AesKeyGenerate() []byte
AesKeyGenerate generates a random 32 byte (256 bit) key for AES-256
Types ¶
type CompressFunc ¶
type CompressFunc func(ctx context.Context, algorithm CompressionType, body []byte, encryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
func GZipCompressGenerator ¶
func GZipCompressGenerator(level int) CompressFunc
type CompressionType ¶ added in v0.0.4
type CompressionType string
Compression or encriprion type
const ( NoCompression CompressionType = "" Zip CompressionType = "gzip" Zip1 CompressionType = "gzip1" Zip9 CompressionType = "gzip9" // Aes - AES 256 alg Aes CompressionType = "aes" )
Algs
func AesDecrypt ¶
func AesDecrypt(ctx context.Context, algorithm CompressionType, body []byte, decryptKey []byte, ) (algorithmUsed CompressionType, result []byte, err *mft.Error)
func AesEncrypt ¶
func AesEncrypt(ctx context.Context, algorithm CompressionType, body []byte, encryptKey []byte, ) (algorithmUsed CompressionType, result []byte, err *mft.Error)
func GZipCompress ¶
func GZipCompress(ctx context.Context, level int, algorithm CompressionType, body []byte, encryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
func GZipRestore ¶
func GZipRestore(ctx context.Context, algorithm CompressionType, body []byte, decryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator - compressor
func GeneratorCreate ¶
GeneratorCreate - generate with default algs
func (*Generator) Add ¶
func (g *Generator) Add(name CompressionType, compressor CompressFunc, restore RestoreFunc)
type RestoreFunc ¶
type RestoreFunc func(ctx context.Context, algorithm CompressionType, body []byte, decryptKey []byte) (algorithmUsed CompressionType, result []byte, err *mft.Error)
Click to show internal directories.
Click to hide internal directories.