Documentation ¶
Index ¶
- Constants
- Variables
- func AnalyzePasswordStrenth(passwd string) seclib.PasswordStrength
- func BcryptPassword(passwd string) (string, error)
- func BcryptVerifyPassword(passwd string, hash string) error
- func CleanCertificate(cert string) string
- func DecodePrivateKey(keyString []byte) (*rsa.PrivateKey, error)
- func Decrypt(privateKey, secret []byte) ([]byte, error)
- func DecryptBase64(privateKey string, secret string) (string, error)
- func Encrypt(publicKey, origData []byte) ([]byte, error)
- func EncryptBase64(publicKey string, message string) (string, error)
- func GenerateDSASSHKeypair() (string, string, error)
- func GeneratePassword(passwd string) (string, error)
- func GenerateRSASSHKeypair() (string, string, error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GetPublicKeyScheme(pubkey ssh.PublicKey) string
- func HashId(seed string, idx byte, width int) string
- func InitTLSConfig(certFile, keyFile string) (*tls.Config, error)
- func InitTLSConfigByData(caCertBlock, certPEMBlock, keyPEMBlock []byte) (*tls.Config, error)
- func InitTLSConfigWithCA(certFile, keyFile, caCertFile string) (*tls.Config, error)
- func MeetComplxity(passwd string) bool
- func MergeCaCertFiles(cafile string, certfile string) (string, error)
- func NewCert(certfile, keyfile string, ...) (*tls.Certificate, error)
- func NewCertPool(CAFiles []string) (*x509.CertPool, error)
- func RandomPassword2(width int) string
- func ValidatePassword(passwd string) error
- func VerifyPassword(passwd string, hash string) error
- type SSymEncAlg
- func (alg SSymEncAlg) CbcDecode(cipherText []byte, encryptionKey []byte) ([]byte, error)
- func (alg SSymEncAlg) CbcDecodeBase64(cipherText string, encryptionKey []byte) ([]byte, error)
- func (alg SSymEncAlg) CbcEncode(content []byte, encryptionKey []byte) ([]byte, error)
- func (alg SSymEncAlg) CbcEncodeBase64(content []byte, encryptionKey []byte) (string, error)
- func (alg SSymEncAlg) CbcEncodeIV(content []byte, encryptionKey []byte, IV []byte) ([]byte, error)
- func (alg SSymEncAlg) GenerateKey() string
- func (alg SSymEncAlg) Name() TSymEncAlg
- type TSymEncAlg
Constants ¶
View Source
const ( SYM_ENC_ALG_AES_256 = TSymEncAlg("aes-256") SYM_ENC_ALG_SM4_128 = TSymEncAlg("sm4") )
Variables ¶
View Source
var ( AES_256 = SSymEncAlg{ // contains filtered or unexported fields } SM4_128 = SSymEncAlg{ // contains filtered or unexported fields } )
View Source
var CERT_SEP = []byte("-END CERTIFICATE-")
Functions ¶
func AnalyzePasswordStrenth ¶
func AnalyzePasswordStrenth(passwd string) seclib.PasswordStrength
func BcryptPassword ¶
func BcryptVerifyPassword ¶
func CleanCertificate ¶
func DecodePrivateKey ¶
func DecodePrivateKey(keyString []byte) (*rsa.PrivateKey, error)
func GenerateDSASSHKeypair ¶
func GeneratePassword ¶
func GenerateRSASSHKeypair ¶
func GenerateRandomBytes ¶
func GetPublicKeyScheme ¶
func InitTLSConfigByData ¶
func InitTLSConfigWithCA ¶
func MeetComplxity ¶
func MergeCaCertFiles ¶
MergeCaCertFiles concatenates cert and ca file to form a chain, write it to a tmpfile then return the path
Callers are responsible for removing the returned tmpfile
func NewCert ¶
func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error)
NewCert generates TLS cert by using the given cert,key and parse function.
func NewCertPool ¶
NewCertPool creates x509 certPool with provided CA files.
func RandomPassword2 ¶
func ValidatePassword ¶
func VerifyPassword ¶
Types ¶
type SSymEncAlg ¶
type SSymEncAlg struct {
// contains filtered or unexported fields
}
func Alg ¶
func Alg(alg TSymEncAlg) SSymEncAlg
func (SSymEncAlg) CbcDecode ¶
func (alg SSymEncAlg) CbcDecode(cipherText []byte, encryptionKey []byte) ([]byte, error)
func (SSymEncAlg) CbcDecodeBase64 ¶
func (alg SSymEncAlg) CbcDecodeBase64(cipherText string, encryptionKey []byte) ([]byte, error)
func (SSymEncAlg) CbcEncode ¶
func (alg SSymEncAlg) CbcEncode(content []byte, encryptionKey []byte) ([]byte, error)
func (SSymEncAlg) CbcEncodeBase64 ¶
func (alg SSymEncAlg) CbcEncodeBase64(content []byte, encryptionKey []byte) (string, error)
func (SSymEncAlg) CbcEncodeIV ¶
AES-256-CBC key: 32bytes=256bites
func (SSymEncAlg) GenerateKey ¶
func (alg SSymEncAlg) GenerateKey() string
func (SSymEncAlg) Name ¶
func (alg SSymEncAlg) Name() TSymEncAlg
type TSymEncAlg ¶
type TSymEncAlg string
Click to show internal directories.
Click to hide internal directories.