Documentation
¶
Index ¶
- func Base64Decode(data string) string
- func Base64Encode(data []byte) string
- func Base64URLDecode(data string) string
- func Base64URLEncode(data []byte) string
- func CheckPassword(rawPwd, encodedPwd string) bool
- func Encode(rawPwd string, options *Options) (string, string)
- func MakePassword(rawPwd string) string
- func SSLCreate()
- func Verify(rawPwd string, salt string, encodedPwd string, options *Options) bool
- type Aes
- func (a *Aes) Decrypt(src []byte) ([]byte, error)
- func (a *Aes) DecryptGcm(data, key, nonce, tag string) (string, error)
- func (a *Aes) DecryptString(src string) (string, error)
- func (a *Aes) Encrypt(src []byte) ([]byte, error)
- func (a *Aes) EncryptGcm(data, key string) (string, string, string)
- func (a *Aes) EncryptString(src string) string
- type AesConfig
- type Options
- type Rsa
- func (r *Rsa) Decrypt(b64Data string) string
- func (r *Rsa) DecryptSha1(ciphertextBase64 string) (string, error)
- func (r *Rsa) Encrypt(plainText []byte) string
- func (r *Rsa) EncryptSha1(dataToEncrypt string) (string, error)
- func (r *Rsa) GenerateKey()
- func (r *Rsa) GeneratePrivateKey() *rsa.PrivateKey
- func (r *Rsa) GeneratePublicKey(privateKey *rsa.PrivateKey)
- func (r *Rsa) Sign(plainText string) string
- func (r *Rsa) Verify(originalData, signData string) bool
- type RsaConfig
- type ZdpPassword
- type ZdpPasswordConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶ added in v0.1.1
Base64Decode 对数据使用base64标准解码
func Base64Encode ¶ added in v0.1.1
Base64Encode 对数据使用base64标准编码
func Base64URLDecode ¶ added in v0.1.1
Base64URLDecode 对数据使用base64 URL解码
func Base64URLEncode ¶ added in v0.1.1
Base64URLEncode 对数据使用base64 URL编码
func CheckPassword ¶
CheckPassword 默认的密码校验方式 @param rawPwd 原始密码 @param encodedPwd 加密后的密码
func Encode ¶
Encode 对密码按照指定配置进行加密。如果参数2是nil,则使用默认的配置。返回加密后的字符串。 @param rawPwd 要加密的密码 @param options 加密配置
func MakePassword ¶
MakePassword 默认的密码加密方式,返回加密的密码 @param rawPwd 要加密的密码
Types ¶
type Aes ¶ added in v0.1.1
type Aes struct {
// contains filtered or unexported fields
}
func (*Aes) DecryptGcm ¶ added in v0.1.1
func (*Aes) DecryptString ¶ added in v0.1.1
DecryptString AES解密字符串
func (*Aes) EncryptGcm ¶ added in v0.1.1
func (*Aes) EncryptString ¶ added in v0.1.1
EncryptString 加密字符串
type AesConfig ¶ added in v0.1.1
type AesConfig struct {
Key string `yaml:"key" json:"key"` // key
BlockSize int `yaml:"block_size" json:"block_size"` // 块的大小
}
Aes AES加密算法的配置
type Rsa ¶ added in v0.1.1
type Rsa struct {
Config *RsaConfig // Rsa配置对象
}
func (*Rsa) Decrypt ¶ added in v0.1.1
Decrypt RSA解密 @param cipherText 需要解密的byte数据 @param privateKeyPath 私钥文件路径
func (*Rsa) DecryptSha1 ¶ added in v0.1.1
DecryptSha1 Sha1方式的RSA解密
func (*Rsa) Encrypt ¶ added in v0.1.1
Encrypt RSA加密 @param plainText 要加密的数据 @param publicKeyPath 公钥匙文件地址
func (*Rsa) EncryptSha1 ¶ added in v0.1.1
EncryptSha1 此算法的加密结果能够被zdppy-python的RSA的decrypt方法解密
func (*Rsa) GenerateKey ¶ added in v0.1.1
func (r *Rsa) GenerateKey()
GenerateKey 生成RSA私钥和公钥,保存到文件中 @param bitSize 证书大小 @param privateKeyName 私钥文件名 @param publicKeyName 公钥文件名
func (*Rsa) GeneratePrivateKey ¶ added in v0.1.1
func (r *Rsa) GeneratePrivateKey() *rsa.PrivateKey
func (*Rsa) GeneratePublicKey ¶ added in v0.1.1
func (r *Rsa) GeneratePublicKey(privateKey *rsa.PrivateKey)
type RsaConfig ¶ added in v0.1.1
type RsaConfig struct {
PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // 私钥文件路径
PublicKeyPath string `yaml:"public_key_path" json:"public_key_path"` // 公钥文件路径
BitSize int `yaml:"bit_size" json:"bit_size"` // 私钥文件的key长度
Debug bool `yaml:"debug" json:"debug"` // 是否为开发环境
}
RsaConfig RSA配置对象
type ZdpPassword ¶
type ZdpPassword struct {
// contains filtered or unexported fields
}
密码加密核心对象
func (*ZdpPassword) Check ¶
func (p *ZdpPassword) Check(userPassword, dataPassword string) bool
Check 检查密码是否正确 @param userPassword 用户输入的密码 @param dataPassword 数据库中加密的密码
func (*ZdpPassword) Make ¶
func (p *ZdpPassword) Make(password string) string
Make 密码加密 @param password 用户要加密的密码
func (*ZdpPassword) Md5 ¶
func (p *ZdpPassword) Md5(content string) string
Md5 生成md5加密字符串 @param content 要加密的内容
type ZdpPasswordConfig ¶
配置对象
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
sslcreate
command
|
|
|
z01_hello
command
|
|
|
z02_aes
command
|
|
|
z03_rsa
command
|
|
|
plugins
|
|
|
pbkdf2
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
|
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. |