encryption

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSalt = "crypto"
)

Functions

func Decode

func Decode(s, key []byte) ([]byte, error)

decode bytes by aes cfb

func Encode

func Encode(s, key []byte) ([]byte, error)

func GetBuf

func GetBuf(size int) []byte

func Join

func Join(c1 io.ReadWriteCloser, c2 io.ReadWriteCloser) (inCount int64, outCount int64, errors []error)

Join two io.ReadWriteCloser and do some operations.

func PutBuf

func PutBuf(buf []byte)

func WrapConn

func WrapConn(conn net.Conn, r io.Reader, w io.Writer, closeFn func() error) net.Conn

closeFn will be called only once

func WrapToTlsConfig

func WrapToTlsConfig(config *configs.TlsConfig) (*tls.Config, error)

func WrapWithEncryption

func WrapWithEncryption(conn net.Conn, key []byte) (net.Conn, error)

func WrapWithTls

func WrapWithTls(lsn net.Listener, config *configs.TlsConfig) (net.Listener, error)

Types

type AESReader

type AESReader struct {
	// contains filtered or unexported fields
}

Reader is an io.Reader that can read encrypted bytes. Now it only supports aes-128-cfb.

func NewAESReader

func NewAESReader(r io.Reader, key []byte) *AESReader

NewAESReader returns a new Reader that decrypts bytes from r

func (*AESReader) Read

func (r *AESReader) Read(p []byte) (nRet int, errRet error)

Read satisfies the io.Reader interface.

type AESWriter

type AESWriter struct {
	// contains filtered or unexported fields
}

Writer is an io.Writer that can write encrypted bytes. Now it only support aes-128-cfb.

func NewAESWriter

func NewAESWriter(w io.Writer, key []byte) (*AESWriter, error)

NewAESWriter returns a new Writer that encrypts bytes to w.

func (*AESWriter) Write

func (w *AESWriter) Write(p []byte) (nRet int, errRet error)

Write satisfies the io.Writer interface.

type WrappedConn

type WrappedConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*WrappedConn) Close

func (rwc *WrappedConn) Close() error

func (*WrappedConn) Read

func (rwc *WrappedConn) Read(p []byte) (n int, err error)

func (*WrappedConn) Write

func (rwc *WrappedConn) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL