Documentation ¶
Index ¶
- Constants
- func GeneratePasswordHash(password, method string) string
- func GetEncryptionMethod(mode string, keySize int) string
- func LoadRSAPrivateKey(data []byte) (*rsa.PrivateKey, error)
- func LoadRSAPrivateKeyFile(pemFile string) (*rsa.PrivateKey, error)
- func LoadRSAPublicKey(data []byte) (*rsa.PublicKey, error)
- func LoadRSAPublicKeyFile(pemFile string) (*rsa.PublicKey, error)
- func MaxEncryptSize(pubkey *rsa.PublicKey) int
- func PKCS5Pad(ciphertext []byte, blockSize int) []byte
- func PKCS5Unpad(encrypted []byte) []byte
- func SignAccessToken(key string, args ...string) string
- func SignEncryptSignature(method string, encrypt AESCryptor, priKey *rsa.PrivateKey) ([]byte, error)
- func VerifyEncryptSignature(method string, signature []byte, encrypt AESCryptor, pubKey *rsa.PublicKey) error
- func VerifyPasswordHash(hashText, password string) bool
- type AESCryptor
Constants ¶
View Source
const ( SALT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" DEFAULT_PBKDF2_ITERATIONS = 310_000 )
Variables ¶
This section is empty.
Functions ¶
func GeneratePasswordHash ¶
GeneratePasswordHash
Hash a password with the given method and salt with a string of the given length. The format of the string returned includes the method that was used so that :func:`check_password_hash` can check the hash. The format for the hashed string looks like this:: method$salt$hash
func GetEncryptionMethod ¶
func LoadRSAPrivateKey ¶
func LoadRSAPrivateKey(data []byte) (*rsa.PrivateKey, error)
LoadRSAPrivateKey 解析私钥文件
func LoadRSAPrivateKeyFile ¶
func LoadRSAPrivateKeyFile(pemFile string) (*rsa.PrivateKey, error)
func LoadRSAPublicKey ¶
LoadRSAPublicKey 解析公钥文件
func PKCS5Unpad ¶
func SignEncryptSignature ¶
func SignEncryptSignature(method string, encrypt AESCryptor, priKey *rsa.PrivateKey) ([]byte, error)
SignEncryptSignature 签名
func VerifyEncryptSignature ¶
func VerifyEncryptSignature(method string, signature []byte, encrypt AESCryptor, pubKey *rsa.PublicKey) error
VerifyEncryptSignature 校验签名
func VerifyPasswordHash ¶
VerifyPasswordHash
check a password against a given salted and hashed password value. In order to support unsalted legacy passwords this method supports plain text passwords, md5 and sha1 hashes (both salted and unsalted).
Types ¶
type AESCryptor ¶
type AESCryptor interface { Key() ([]byte, []byte) Encrypt([]byte) ([]byte, error) Decrypt([]byte) ([]byte, error) }
AESCryptor https://en.wikipedia.org/wiki/Advanced_Encryption_Standard
func CreateAESCryptor ¶
func CreateAESCryptor(method string) (AESCryptor, error)
CreateAESCryptor `method` is like "aes-128-cbc", "aes-256-ctr", "aes-192-gcm"
func NewAESCryptor ¶
func NewAESCryptor(mode string, key, iv []byte) (AESCryptor, error)
Click to show internal directories.
Click to hide internal directories.