cryptorHelper

package
v1.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DERToPrivateKey

func DERToPrivateKey(der []byte) (key interface{}, err error)

DERToPrivateKey 一个工具函数,把DER转化成一个private key:

func MD5Encrypt

func MD5Encrypt(raw string) string

MD5Encrypt MD5加密

func MarshalPKCS8PrivateKey

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

MarshalPKCS8PrivateKey 使用golang的rsa包生成的私钥默认是pkcs1的.如果将pkcs1转化为pkcs8格式的

func SHA1EncryptOld

func SHA1EncryptOld(data string) string

SHA1EncryptOld 对字符串进行SHA1哈希

func SHA1Hash

func SHA1Hash(data string) string

SHA1Hash 对字符串进行SHA1哈希

func SHA256Hash

func SHA256Hash(data string) string

SHA256Hash 对字符串进行SHA256哈希

Types

type RsaHelper

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

func NewRsaHelper

func NewRsaHelper(publicKey, privateKey string) (rsaM *RsaHelper, err error)

func (*RsaHelper) CreateKeys

func (r *RsaHelper) CreateKeys(keyLength int) (privateKey, publicKey string)

CreateKeys 生成pkcs1 格式的公钥私钥

func (*RsaHelper) CreatePkcs8Keys

func (r *RsaHelper) CreatePkcs8Keys(keyLength int) (privateKey, publicKey string)

CreatePkcs8Keys 生成pkcs8 格式公钥私钥

func (*RsaHelper) Decrypt

func (r *RsaHelper) Decrypt(data []byte) ([]byte, error)

Decrypt 解密

func (*RsaHelper) Encrypt

func (r *RsaHelper) Encrypt(data []byte) ([]byte, error)

Encrypt 加密

func (*RsaHelper) Pkcs1ToPkcs8

func (r *RsaHelper) Pkcs1ToPkcs8(key []byte) []byte

Pkcs1ToPkcs8 将pkcs1 转到 pkcs8 自定义

func (*RsaHelper) Sign

func (r *RsaHelper) Sign(data []byte, sHash crypto.Hash) ([]byte, error)

Sign 签名

func (*RsaHelper) Verify

func (r *RsaHelper) Verify(data []byte, sign []byte, sHash crypto.Hash) error

Verify 验签

Jump to

Keyboard shortcuts

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