Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(ctx context.Context, algorithm string, body []byte, decryptKey []byte) (algorithmUsed string, result []byte, err *mft.Error)
- func AesEncrypt(ctx context.Context, algorithm string, body []byte, encryptKey []byte) (algorithmUsed string, result []byte, err *mft.Error)
- func AesKeyGenerate() []byte
- func GZipCompress(ctx context.Context, level int, algorithm string, body []byte, ...) (algorithmUsed string, result []byte, err *mft.Error)
- func GZipRestore(ctx context.Context, algorithm string, body []byte, decryptKey []byte) (algorithmUsed string, result []byte, err *mft.Error)
- func GenerateError(key int, a ...interface{}) *mft.Error
- func GenerateErrorE(key int, err error, a ...interface{}) *mft.Error
- type CompressFunc
- type Generator
- func (g *Generator) Add(name string, compressor CompressFunc, restore RestoreFunc)
- func (g *Generator) Compress(ctx context.Context, must bool, algorithm string, body []byte, ...) (algorithmUsed string, result []byte, err *mft.Error)
- func (g *Generator) Init()
- func (g *Generator) Restore(ctx context.Context, algorithm string, body []byte, decryptKey []byte) (algorithmUsed string, result []byte, err *mft.Error)
- type RestoreFunc
Constants ¶
View Source
const ( NoCompression = "" Zip = "gzip" Zip1 = "gzip1" Zip9 = "gzip9" // Aes - AES 256 alg Aes = "aes" )
Algs
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 AesDecrypt ¶
func AesEncrypt ¶
func AesKeyGenerate ¶
func AesKeyGenerate() []byte
AesKeyGenerate generates a random 32 byte (256 bit) key for AES-256
func GZipCompress ¶
func GZipRestore ¶
Types ¶
type CompressFunc ¶
type CompressFunc func(ctx context.Context, algorithm string, body []byte, encryptKey []byte) (algorithmUsed string, result []byte, err *mft.Error)
func GZipCompressGenerator ¶
func GZipCompressGenerator(level int) CompressFunc
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 string, compressor CompressFunc, restore RestoreFunc)
Click to show internal directories.
Click to hide internal directories.