encrypt

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package encrypt implement common encrypt and decrypt

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CipherMethods

func CipherMethods() []string

CipherMethods 获取Cipher的所有支持方法

func Evp2Key

func Evp2Key(password string, keyLen int) (key []byte)

Evp2Key evp to key

func HasCipherMethod

func HasCipherMethod(method string) (ok bool)

HasCipherMethod 是否有method方法

func NewStream added in v0.0.4

func NewStream(method string, key, iv []byte, encrypt bool) (cipher.Stream, error)

NewStream new stream

func Valid added in v0.0.8

func Valid(method, password string) bool

Valid method password is valid or not

Types

type Cipher

type Cipher struct {
	Write cipher.Stream
	Read  cipher.Stream
}

Cipher implement write and read cipher.Stream

func NewCipher

func NewCipher(method, password string) (*Cipher, error)

NewCipher new cipher method support:

aes-128-cfb
aes-192-cfb
aes-256-cfb
aes-128-ctr
aes-192-ctr
aes-256-ctr
aes-128-ofb
aes-192-ofb
aes-256-ofb
des-cfb
des-ctr
des-ofb
blowfish-cfb
blowfish-ctr
blowfish-ofb
cast5-cfb
cast5-ctr
cast5-ofb
twofish-128-cfb
twofish-192-cfb
twofish-256-cfb
twofish-128-ctr
twofish-192-ctr
twofish-256-ctr
twofish-128-ofb
twofish-192-ofb
twofish-256-ofb
tea-cfb
tea-ctr
tea-ofb
xtea-cfb
xtea-ctr
xtea-ofb
rc4-md5
rc4-md5-6
chacha20
chacha20-ietf
salsa20

type CipherInfo

type CipherInfo struct {
	KeyLen    int
	IvLen     int
	NewStream func(key, iv []byte, encrypt bool) (cipher.Stream, error)
}

CipherInfo cipher information

func GetCipherInfo

func GetCipherInfo(method string) (info CipherInfo, ok bool)

GetCipherInfo 根据方法获得 Cipher information

Jump to

Keyboard shortcuts

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