Documentation
¶
Index ¶
Constants ¶
View Source
const ( RsaDefaultPublishKeyName = "publishKey" RsaDefaultPrivateKeyName = "privateKey" PublishKey = "PUBLIC KEY" PrivateKey = "RSA PRIVATE KEY" )
View Source
const AesKeyLength = 16
View Source
const DesKeyLength = 8
View Source
const TripleDesKeyBlock = 8
View Source
const TripleDesKeyLength = 24
Variables ¶
View Source
var AesBaseSpecialSign = "!@a%$bc.de,l%$fgqweruriskn&#@xl784zm321apgiw"
View Source
var AesBaseSpecialSignLength = len(AesBaseSpecialSign)
View Source
var DesBaseSpecialSign = "!%$brgil%$kn&weruxl7c.de,fq8zm32#@1a4pgiw@a"
View Source
var DesBaseSpecialSignLength = len(DesBaseSpecialSign)
View Source
var RsaBitsMap = map[RsaBitsType]int{ RsaBits512: 512, RsaBits1024: 1024, RsaBits2048: 2048, RsaBits4096: 4096, }
View Source
var TripleDesBaseSpecialSign = "!@abc$qwefgr.#n3@zmde,l%uri&%18$xl7g42askpiw"
View Source
var TripleDesBaseSpecialSignLength = len(TripleDesBaseSpecialSign)
Functions ¶
This section is empty.
Types ¶
type AesEncrypt ¶
type AesEncrypt struct { SpecialSign string // 加解密都会基于这一串字符,如果没有会基于 AesBaseSpecialSign. Key string // 密钥,建议是 5-8位的密钥 }
func NewAesEncrypt ¶
func NewAesEncrypt(specialSign, key string) (*AesEncrypt, error)
func (*AesEncrypt) SecretDecrypt ¶
func (a *AesEncrypt) SecretDecrypt(secret interface{}, fields ...interface{}) string
SecretDecrypt 解密
func (*AesEncrypt) SecretEncrypt ¶
func (a *AesEncrypt) SecretEncrypt(secret interface{}, fields ...interface{}) string
SecretEncrypt 加密
type DesEncrypt ¶
type DesEncrypt struct { SpecialSign string // 加解密都会基于这一串字符,如果没有会基于 DesBaseSpecialSign. Key string // 密钥,建议是 5-8位的密钥 }
func NewDesEncrypt ¶
func NewDesEncrypt(specialSign, key string) (*DesEncrypt, error)
func (*DesEncrypt) SecretDecrypt ¶
func (d *DesEncrypt) SecretDecrypt(secret interface{}, fields ...interface{}) (string, error)
SecretDecrypt 解密
func (*DesEncrypt) SecretEncrypt ¶
func (d *DesEncrypt) SecretEncrypt(secret interface{}, fields ...interface{}) (string, error)
SecretEncrypt 加密
type RsaBitsType ¶
type RsaBitsType int
const ( RsaBits512 RsaBitsType = 512 RsaBits1024 RsaBitsType = 1024 RsaBits2048 RsaBitsType = 2048 RsaBits4096 RsaBitsType = 4096 RsaDefaultBits = RsaBits1024 )
type RsaEncrypt ¶
type RsaEncrypt struct { Bits RsaBitsType // 定位大小的 RSA 密钥对 PublishKeyName string // 公钥名字 PrivateKeyName string // 私钥名字 PublishKeyPath string // 公钥的输出路径 PrivateKeyPath string // 私钥的输出路径 }
func NewDefaultRsaEncrypt ¶
func NewDefaultRsaEncrypt() *RsaEncrypt
func NewRsaEncrypt ¶
func NewRsaEncrypt(bits RsaBitsType, publishKeyName, publishKeyPath, privateKeyName, privateKeyPath string) *RsaEncrypt
func (*RsaEncrypt) RsaDecoding ¶
func (r *RsaEncrypt) RsaDecoding(srcByte []byte, filePath string) ([]byte, error)
RsaDecoding 解密
func (*RsaEncrypt) RsaEncoding ¶
func (r *RsaEncrypt) RsaEncoding(src, filePath string) ([]byte, error)
RsaEncoding 加密
type TripleDesEncrypt ¶
type TripleDesEncrypt struct { SpecialSign string // 加解密都会基于这一串字符,如果没有会基于 TripleDesBaseSpecialSign. Key string // 密钥,建议是 5-8位的密钥 }
func NewTripleDesEncrypt ¶
func NewTripleDesEncrypt(specialSign, key string) (*TripleDesEncrypt, error)
func (*TripleDesEncrypt) SecretDecrypt ¶
func (t *TripleDesEncrypt) SecretDecrypt(secret interface{}, fields ...interface{}) (string, error)
SecretDecrypt 解密
func (*TripleDesEncrypt) SecretEncrypt ¶
func (t *TripleDesEncrypt) SecretEncrypt(secret interface{}, fields ...interface{}) (string, error)
SecretEncrypt 加密
Click to show internal directories.
Click to hide internal directories.