mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 04:10:25 +08:00
33 lines
770 B
Go
33 lines
770 B
Go
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud .
|
|
|
|
package iplibrary
|
|
|
|
import "github.com/TeaOSLab/EdgeCommon/pkg/nodeutils"
|
|
|
|
type Encrypt struct {
|
|
}
|
|
|
|
func NewEncrypt() *Encrypt {
|
|
return &Encrypt{}
|
|
}
|
|
|
|
func (this *Encrypt) Encode(srcData []byte, password string) ([]byte, error) {
|
|
var method = nodeutils.AES256CFBMethod{}
|
|
err := method.Init([]byte(password), []byte(password))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return method.Encrypt(srcData)
|
|
}
|
|
|
|
func (this *Encrypt) Decode(encodedData []byte, password string) ([]byte, error) {
|
|
var method = nodeutils.AES256CFBMethod{}
|
|
err := method.Init([]byte(password), []byte(password))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return method.Decrypt(encodedData)
|
|
}
|