xcrypt

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

XCrypt

提供了快速加解密的方法。

AES

package xcrypt
// 参数分别对应 要加密的数据, 密钥, 初始化向量
// 加密
func AesEncryptRaw(data []byte, key []byte, iv []byte) ([]byte, error)
// 解密
func AesDecryptRaw(data []byte, key []byte, iv []byte) ([]byte, error)

Bcrypt

bcrypt 提供了密码加密/验证相关的操作。

brcypt主要思想是拖慢破解的速度,在cost为10的情况下,加密要比md5慢上百万倍,对应的暴力破解也是如此。 在值域一定的情况下,破解越慢, 被破解的可能性越低,从而保护密码的安全。

package xcrypt
func SetCost(cost int) {}

func BCryptHash(password []byte) ([]byte, error) {}

func BCryptValidate(password []byte, encryptedData []byte) bool {}

Documentation

Index

Constants

View Source
const AesCipherKeySize = 32 // aes key size, 256 bit

Variables

This section is empty.

Functions

func AesDecryptRaw

func AesDecryptRaw(data []byte, key []byte, iv []byte) ([]byte, error)

AesDecryptRaw decrypt original `data` with `key` and initializer vector `iv` iv should have at least `aes.BlockSize` length

func AesEncryptRaw

func AesEncryptRaw(data []byte, key []byte, iv []byte) ([]byte, error)

AesEncryptRaw encrypt original `data` with `key` and initializer vector `iv` iv should have at least `aes.BlockSize` length

func BCryptHash

func BCryptHash(password []byte) ([]byte, error)

BCryptHash encrypt original password with bcryptCost to encrypted data, then store encrypted data into database.

func BCryptValidate

func BCryptValidate(password []byte, encryptedData []byte) bool

BCryptValidate validate password and encryptedData retrieved from database.

func SetBCryptCost

func SetBCryptCost(cost int)

SetBCryptCost set global bcrypt cost, and after, all encrypt operation use this call before changed again

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL