bcrypto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 17 Imported by: 0

README

此包下是用于处理加密相关的内容

Documentation

Index

Constants

View Source
const (
	CHAR_SET               = "UTF-8"
	BASE_64_FORMAT         = "UrlSafeNoPadding"
	RSA_ALGORITHM_KEY_TYPE = "PKCS8"
	RSA_ALGORITHM_SIGN     = crypto.SHA256
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, iv []byte) ([]byte, error)

AES解密

func AesDecryptString

func AesDecryptString(crypted, iv string) (string, error)

字符串方式解密

func AesEncrypt

func AesEncrypt(origData, iv []byte) ([]byte, error)

AES加密,CBC

func AesEncryptString

func AesEncryptString(src, blockSize string) (string, error)

字符串方式加密

func CreateKeys

func CreateKeys(publicKeyWriter, privateKeyWriter io.Writer, keyLength int) error

生成密钥对

func MarshalPKCS8PrivateKey

func MarshalPKCS8PrivateKey(key *rsa.PrivateKey) []byte

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(src []byte) ([]byte, error)

func PwdSlat

func PwdSlat(password, slat string) string

PwdSlat 给密码通过盐加密

func PwdSlatWithInt64Hex16

func PwdSlatWithInt64Hex16(password string, i64 int64) string

PwdSlatWithInt64Hex16 给密码加盐, 盐是 int64 格式的的数字转成 16 进制字符串

func SlatBuilder

func SlatBuilder(a ...int) string

SlatBuilder 创建随机的加盐字符串

Types

type XRsa

type XRsa struct {
	// contains filtered or unexported fields
}

func NewXRsa

func NewXRsa(publicKey []byte, privateKey []byte) (*XRsa, error)

func (*XRsa) PrivateDecrypt

func (r *XRsa) PrivateDecrypt(encrypted string) (string, error)

私钥解密

func (*XRsa) PublicEncrypt

func (r *XRsa) PublicEncrypt(data string) (string, error)

公钥加密

func (*XRsa) Sign

func (r *XRsa) Sign(data []byte) (string, error)

数据加签

func (*XRsa) Verify

func (r *XRsa) Verify(data string, sign string) error

数据验签

func (*XRsa) VerifyStdEncoding

func (r *XRsa) VerifyStdEncoding(data string, sign string) error

VerifyStdEncoding 数据验签, 使用 StdEncoding 解开 base64

Jump to

Keyboard shortcuts

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