24 lines
383 B
Go
24 lines
383 B
Go
|
|
package cipher
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Cipher interface {
|
||
|
|
Decrypt(data []byte) (decrypted []byte, err error)
|
||
|
|
Encrypt(data []byte) (encryped []byte, err error)
|
||
|
|
}
|
||
|
|
|
||
|
|
type Carrier struct {
|
||
|
|
Conn net.Conn
|
||
|
|
Cipher Cipher
|
||
|
|
Cache []byte
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewCipher(cipherName string) (cipher Cipher) {
|
||
|
|
if cipherName == "default" {
|
||
|
|
return NewChaCha()
|
||
|
|
}
|
||
|
|
return nil //TODO:临时这样处理
|
||
|
|
}
|