Documentation ¶
Index ¶
- func CreateMd5Password(password string) string
- func CreatePassword(password string) string
- func CreateToken(prefix []byte, tailsize int) string
- func GetPasswordChanges(password string) map[string]any
- func Md5(data string) string
- func Md5File(filename string) (string, error)
- func Md5Sum(data string) string
- func NewSerialNo(n byte) string
- func NewTimeSerialNo(n byte, t time.Time) string
- func PKCS5Padding(cipherText []byte, blockSize int) []byte
- func PKCS5Unpadding(origData []byte) []byte
- func PKCS7Padding(cipherText []byte, blockSize int) []byte
- func PKCS7Unpadding(origData []byte) []byte
- func RandSalt(size int) string
- func VerifyPassword(plainText, cipherText string) bool
- func ZeroPadding(cipherText []byte, blockSize int) []byte
- func ZeroUnpadding(origData []byte) []byte
- type AESCipher
- func (c *AESCipher) Decrypt(cipherText []byte) ([]byte, error)
- func (c *AESCipher) Encrypt(origData []byte) ([]byte, error)
- func (c *AESCipher) GetDecrypter() cipher.BlockMode
- func (c *AESCipher) GetEncrypter() cipher.BlockMode
- func (c *AESCipher) GetStream(isDecrypt bool) cipher.Stream
- func (c *AESCipher) SetPaddingFunc(name string)
- type ICipher
- type MacHash
- type NewHashFunc
- type PaddingFunc
- type RSACipher
- func (c RSACipher) Decrypt(cipherText []byte) ([]byte, error)
- func (c RSACipher) Encrypt(origData []byte) ([]byte, error)
- func (c RSACipher) GetBlock(key []byte, errmsg string) (*pem.Block, error)
- func (c RSACipher) GetPrivateKey() (*rsa.PrivateKey, error)
- func (c RSACipher) GetPublicKey() (*rsa.PublicKey, error)
- func (c RSACipher) Sign(hash crypto.Hash, msg []byte) ([]byte, error)
- func (c RSACipher) Verify(hash crypto.Hash, msg, sig []byte) error
- type SaltPassword
- type UnpaddingFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMd5Password ¶
func CreatePassword ¶
func CreateToken ¶
func GetPasswordChanges ¶
func NewSerialNo ¶
func PKCS5Padding ¶
func PKCS5Unpadding ¶
func PKCS7Padding ¶
func PKCS7Unpadding ¶
func VerifyPassword ¶
func ZeroPadding ¶
func ZeroUnpadding ¶
Types ¶
type AESCipher ¶
type AESCipher struct { Padding PaddingFunc Unpadding UnpaddingFunc cipher.Block // contains filtered or unexported fields }
AES加密,支持模式CBC、CFB、CTR、OFB,不支持ECB和GCM 其中CBC模式一般需要填充,用法: c.SetPaddingFunc("PKCS5")
func (*AESCipher) GetDecrypter ¶
func (*AESCipher) GetEncrypter ¶
func (*AESCipher) SetPaddingFunc ¶
type ICipher ¶
type MacHash ¶
type MacHash struct {
// contains filtered or unexported fields
}
MacHash 例如 NewMacHash(sha256.New).SetKey("nonce")
func NewMacHash ¶
func NewMacHash(creator NewHashFunc) *MacHash
type NewHashFunc ¶
type PaddingFunc ¶
type RSACipher ¶
type RSACipher struct {
// contains filtered or unexported fields
}
RSA加密,支持模式PKCS#1 v1.5,不支持OAEP/PSS 用法: NewRSACipher(privKey, pubKey).Sign(crypto.SHA256, []byte("hello world"))
func NewRSACipher ¶
func (RSACipher) GetPrivateKey ¶
func (c RSACipher) GetPrivateKey() (*rsa.PrivateKey, error)
type SaltPassword ¶
type SaltPassword struct { *MacHash // contains filtered or unexported fields }
SaltPassword 带salt值的sha256密码哈希
func NewSaltPassword ¶
func NewSaltPassword(len int, sep string) *SaltPassword
func (*SaltPassword) CreatePassword ¶
func (p *SaltPassword) CreatePassword(plainText string) string
CreatePassword 设置密码
func (*SaltPassword) VerifyPassword ¶
func (p *SaltPassword) VerifyPassword(plainText, cipherText string) bool
VerifyPassword 校验密码
type UnpaddingFunc ¶
Click to show internal directories.
Click to hide internal directories.