Documentation ¶
Index ¶
- Variables
- func AddCipher(oid asn1.ObjectIdentifier, cipher CipherFunc)
- func AllCipher() map[string]CipherFunc
- func CheckCipher(c Cipher) bool
- func CheckCipherFromName(name string) bool
- func DerivedKeyPbkdf1(password string, salt string, iter int, keyLen int, ivLen int, ...) ([]byte, []byte)
- func DerivedKeyPkcs12(password string, salt string, iter int, keyLen int, ivLen int, ...) ([]byte, []byte)
- func GetCipherName(c Cipher) string
- type Cipher
- type CipherBlockCBC
- func (this CipherBlockCBC) Decrypt(password, params, ciphertext []byte) ([]byte, error)
- func (this CipherBlockCBC) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)
- func (this CipherBlockCBC) HasKeyLength() bool
- func (this CipherBlockCBC) KeySize() int
- func (this CipherBlockCBC) NeedBmpPassword() bool
- func (this CipherBlockCBC) OID() asn1.ObjectIdentifier
- func (this CipherBlockCBC) WithDerivedKeyFunc(derivedKeyFunc DerivedKeyFunc) CipherBlockCBC
- func (this CipherBlockCBC) WithHasKeyLength(hasKeyLength bool) CipherBlockCBC
- func (this CipherBlockCBC) WithKeySize(keySize int) CipherBlockCBC
- func (this CipherBlockCBC) WithNeedBmpPassword(needBmpPass bool) CipherBlockCBC
- func (this CipherBlockCBC) WithSaltSize(saltSize int) CipherBlockCBC
- type CipherFunc
- type CipherRC4
- func (this CipherRC4) Decrypt(password, params, ciphertext []byte) ([]byte, error)
- func (this CipherRC4) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)
- func (this CipherRC4) HasKeyLength() bool
- func (this CipherRC4) KeySize() int
- func (this CipherRC4) NeedBmpPassword() bool
- func (this CipherRC4) OID() asn1.ObjectIdentifier
- func (this CipherRC4) WithDerivedKeyFunc(derivedKeyFunc DerivedKeyFunc) CipherRC4
- func (this CipherRC4) WithHasKeyLength(hasKeyLength bool) CipherRC4
- func (this CipherRC4) WithNeedBmpPassword(needBmpPass bool) CipherRC4
- func (this CipherRC4) WithSaltSize(saltSize int) CipherRC4
- type Ciphers
- type DerivedKeyFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var MD2AndDES = CipherBlockCBC{ // contains filtered or unexported fields }
PBES1
View Source
var MD2AndRC2_64 = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var MD5AndCAST5 = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var MD5AndDES = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var MD5AndRC2_64 = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var PEMCipherMap = map[string]Cipher{ "SHA1AndRC4_128": SHA1AndRC4_128, "SHA1AndRC4_40": SHA1AndRC4_40, "SHA1And3DES": SHA1And3DES, "SHA1And2DES": SHA1And2DES, "SHA1AndRC2_128": SHA1AndRC2_128, "SHA1AndRC2_40": SHA1AndRC2_40, "MD5AndCAST5": MD5AndCAST5, "SHAAndTwofish": SHAAndTwofish, "MD2AndDES": MD2AndDES, "MD2AndRC2_64": MD2AndRC2_64, "MD5AndDES": MD5AndDES, "MD5AndRC2_64": MD5AndRC2_64, "SHA1AndDES": SHA1AndDES, "SHA1AndRC2_64": SHA1AndRC2_64, }
PEMCipher 列表
View Source
var SHA1And2DES = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var SHA1And3DES = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var SHA1AndDES = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var SHA1AndRC2_128 = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var SHA1AndRC2_40 = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var SHA1AndRC2_64 = CipherBlockCBC{ // contains filtered or unexported fields }
View Source
var SHA1AndRC4_128 = CipherRC4{ // contains filtered or unexported fields }
pkcs12
View Source
var SHA1AndRC4_40 = CipherRC4{ // contains filtered or unexported fields }
View Source
var SHAAndTwofish = CipherBlockCBC{ // contains filtered or unexported fields }
use 32 bytes key length
Functions ¶
func DerivedKeyPbkdf1 ¶ added in v1.0.2032
func DerivedKeyPbkdf1(password string, salt string, iter int, keyLen int, ivLen int, h func() hash.Hash) ([]byte, []byte)
生成密钥
Types ¶
type Cipher ¶
type Cipher interface { // oid OID() asn1.ObjectIdentifier // 值大小 KeySize() int // 是否有 KeyLength HasKeyLength() bool // 密码是否需要 Bmp 处理 NeedBmpPassword() bool // 加密, 返回: [加密后数据, 参数, error] Encrypt(rand io.Reader, key, plaintext []byte) ([]byte, []byte, error) // 解密 Decrypt(key, params, ciphertext []byte) ([]byte, error) }
加密接口
type CipherBlockCBC ¶
type CipherBlockCBC struct {
// contains filtered or unexported fields
}
cbc 模式加密
func (CipherBlockCBC) Decrypt ¶
func (this CipherBlockCBC) Decrypt(password, params, ciphertext []byte) ([]byte, error)
解密
func (CipherBlockCBC) Encrypt ¶
func (this CipherBlockCBC) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)
加密
func (CipherBlockCBC) HasKeyLength ¶ added in v1.0.2039
func (this CipherBlockCBC) HasKeyLength() bool
是否有 KeyLength
func (CipherBlockCBC) NeedBmpPassword ¶ added in v1.0.2066
func (this CipherBlockCBC) NeedBmpPassword() bool
密码是否需要 Bmp 处理
func (CipherBlockCBC) WithDerivedKeyFunc ¶ added in v1.0.2032
func (this CipherBlockCBC) WithDerivedKeyFunc(derivedKeyFunc DerivedKeyFunc) CipherBlockCBC
设置 derivedKeyFunc
func (CipherBlockCBC) WithHasKeyLength ¶ added in v1.0.2039
func (this CipherBlockCBC) WithHasKeyLength(hasKeyLength bool) CipherBlockCBC
func (CipherBlockCBC) WithKeySize ¶ added in v1.0.2072
func (this CipherBlockCBC) WithKeySize(keySize int) CipherBlockCBC
设置 saltSize
func (CipherBlockCBC) WithNeedBmpPassword ¶ added in v1.0.2066
func (this CipherBlockCBC) WithNeedBmpPassword(needBmpPass bool) CipherBlockCBC
func (CipherBlockCBC) WithSaltSize ¶
func (this CipherBlockCBC) WithSaltSize(saltSize int) CipherBlockCBC
设置 saltSize
type CipherRC4 ¶
type CipherRC4 struct {
// contains filtered or unexported fields
}
rc4 模式加密
func (CipherRC4) HasKeyLength ¶ added in v1.0.2039
是否有 KeyLength
func (CipherRC4) NeedBmpPassword ¶ added in v1.0.2066
密码是否需要 Bmp 处理
func (CipherRC4) WithDerivedKeyFunc ¶ added in v1.0.2032
func (this CipherRC4) WithDerivedKeyFunc(derivedKeyFunc DerivedKeyFunc) CipherRC4
设置 derivedKeyFunc
func (CipherRC4) WithHasKeyLength ¶ added in v1.0.2039
func (CipherRC4) WithNeedBmpPassword ¶ added in v1.0.2066
func (CipherRC4) WithSaltSize ¶
设置 saltSize
type Ciphers ¶ added in v1.0.2032
type Ciphers struct {
// contains filtered or unexported fields
}
Ciphers
func NewCiphers ¶ added in v1.0.2032
func NewCiphers() *Ciphers
func (*Ciphers) AddCipher ¶ added in v1.0.2032
func (this *Ciphers) AddCipher(oid asn1.ObjectIdentifier, cipher CipherFunc)
添加加密
Click to show internal directories.
Click to hide internal directories.