ccrypt

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ccrypt 实现net.conn的加密conn接口 aes cfb加密码的连接,通过提供的配置使用pbkdf2生成key, 依靠key和hash生成iv

Index

Constants

View Source
const (
	DefaultIterations = 2048
	DefaultKeySize    = 32 // 32byte 256bits
)

Config defaults

Variables

View Source
var (
	DefaultHash = sha256.New
	DefaultSalt = []byte(`dfaod..ga'.';dfa,;dfa',';023pkadb;j90[[q93jr4poemf';adm;lcv;aodfm'a;dlm[f09eqegoain;lfgankd;gihqp8e8hladknaldkpq3h4''`) // nolint: lll
)

Config defaults

Functions

This section is empty.

Types

type Config

type Config struct {
	Password   string           // 用户加密密钥
	Salt       []byte           // default: DefaultSalt
	Iterations int              // 迭代次数,次数越多加密与解密所需时间越长, default: 2048
	KeySize    int              // 期望密文长度,支持16,24,32, default: 32
	Hash       func() hash.Hash // 加密所使用的hash函数, default: DefaultHash(sha256.New)
}

Config PBKDF2 key 生成的参数配置

type Conn

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

Conn conn with ...

func New

func New(c net.Conn, cfg Config) *Conn

New 创建一个aes cfb加密码的连接,通过提供的配置使用pbkdf2生成key,依靠key和hash生成iv

func (*Conn) Read

func (sf *Conn) Read(p []byte) (int, error)

Read reads data from the connection.

func (*Conn) Write

func (sf *Conn) Write(p []byte) (int, error)

Write writes data to the connection.

Jump to

Keyboard shortcuts

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