Documentation ¶
Index ¶
- func DecryptAesCbc(key string, cipherText string) (string, error)
- func EncryptAesCbc(key string, clearText string) (string, error)
- func GenerateSalt(size int) ([]byte, error)
- func PKCS5Padding(clearText []byte, blockSize int) []byte
- func PKCS5Trimming(encrypt []byte) []byte
- func Pbkdf2Hash256(password string, salt []byte, iter int) string
- func Pbkdf2Hash512(password string, salt []byte, iter int) string
- func Pbkdf2Match256(hash string, password string, salt []byte, iter int) bool
- func Pbkdf2Match512(hash string, password string, salt []byte, iter int) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptAesCbc ¶
DecryptAesCbc returns a decrypted text.
key := "key..." cipherText := "cipher text..." // decrypt the cipher text cipherText, err := DecryptAesCbc(key, cipherText) if err != nil { panic(err) }
func EncryptAesCbc ¶
EncryptAesCbc returns a cipher text.
saltSize := 16 salt, err := libcrypto.GenerateSalt(saltSize) if err != nil { t.Errorf("Failed to generate salt: %v", err) } // compute a 256-bit password hash with salt and 100000 iterations key := libcrypto.Pbkdf2Hash256("password", salt, 100000) clearText := "test to encrypt" // encrypt the clear text cipherText, err := EncryptAesCbc(key, clearText) if err != nil { panic(err) }
func PKCS5Padding ¶
PKCS5Padding returns a padded text.
func PKCS5Trimming ¶
PKCS5Trimming returns a encrypted bytes without padding.
func Pbkdf2Hash256 ¶
Pbkdf2Hash256 returns a PBKDF2-SHA256 hash of the given password.
saltSize := 16 salt, err := GenerateSalt(saltSize) if err != nil { panic(err) } // compute a 256-bit password hash with salt and 100000 iterations hash := Pbkdf2Hash256("password", salt, 100000)
func Pbkdf2Hash512 ¶
Pbkdf2Hash512 returns a PBKDF2-SHA512 hash of the given password.
saltSize := 16 salt, err := GenerateSalt(saltSize) if err != nil { panic(err) } // compute a 512-bit password hash with salt and 100000 iterations hash := Pbkdf2Hash512("password", salt, 100000)
func Pbkdf2Match256 ¶
Pbkdf2Match256 validates the given password against the given hash (256-bit hash).
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.