cipher

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RSATestPrivateKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC0wugAtwSpvDgiYKi6GC5390KYQy4bAC2jBO13zVW5aQ83WPUH
yvhXnj1N1xujGHMJyNGwEYA9voxmPxyYn83D4cRMBga/GaJtLzbJwakpFMaEzUtI
q8bCgPSTXtxuUx+spw6G/yl6MxO9O+RhScDrQPmpjvB4Z/u0Dl5tdwJPqQIDAQAB
AoGATEj9NGAIvcFLR2bXjkHqSoK1PiEL8iUvHV9VAHxNs0PdQhRuxG0qRX/oi1M+
vKPy2KxBojagkm46PmRgIyE96rkI94boLKfctuMVsqg22GQDtcvBuSVrYPNfgDLw
1EbzQihFqgxO/QYnuakn7GAE4N9x1R5gAQr7Wy00aekhHkkCQQDlZgzAYAyFtZA4
A6NOGGPVM8/FLYwUZVyb9jh1uXJiOEj1j7p5bJhUrXRRduJ+Z2t4OP993OprTV86
slO/QVkvAkEAybkBY2JIK+nDxdxCEmbMcQRolTL/l/MQayBF0lbOVHb5svDdpWbm
q9Y6PwfVK8jbp8bJWYovDJ2wEQF3d0R+pwJAH+wzmhHDrFe32hOnhhaezeyH3UiZ
Vb1FRe7drIRCBqkOfh2iNYOHL0F0DmIc4rpBmllUNI+pj4UU23Y1cUgGwQJALBhq
+0Siria9iuTo9IjQK+xgyCyLvrV9Y018tcwP8lrHnpwUd3GU/v8nYFvf92BC09wa
a55PRpy5vh3p9YJdhQJBAKtEEaC8EB7ghXvvo1O+MJotd+EqO330JsLTUf0GcsjI
zV/yJu951ELuzMZTfemh6l8stjjDYlRvZVPbjwrZP8g=
-----END RSA PRIVATE KEY-----`)
View Source
var RSATestPublicKey = []byte(`-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0wugAtwSpvDgiYKi6GC5390KY
Qy4bAC2jBO13zVW5aQ83WPUHyvhXnj1N1xujGHMJyNGwEYA9voxmPxyYn83D4cRM
Bga/GaJtLzbJwakpFMaEzUtIq8bCgPSTXtxuUx+spw6G/yl6MxO9O+RhScDrQPmp
jvB4Z/u0Dl5tdwJPqQIDAQAB
-----END PUBLIC KEY-----`)

Functions

func LoadRSAPrivateKey

func LoadRSAPrivateKey(data []byte) (*rsa.PrivateKey, error)

解析私钥文件

func LoadRSAPrivateKeyFile

func LoadRSAPrivateKeyFile(pemFile string) (*rsa.PrivateKey, error)

func LoadRSAPublicKey

func LoadRSAPublicKey(data []byte) (*rsa.PublicKey, error)

解析公钥文件

func LoadRSAPublicKeyFile

func LoadRSAPublicKeyFile(pemFile string) (*rsa.PublicKey, error)

func MaxEncryptSize

func MaxEncryptSize(pubkey *rsa.PublicKey) int

最大加密内容大小

Types

type BlockCryptor

type BlockCryptor interface {
	Key() []byte
	IV() []byte

	Encrypt(src []byte) []byte
	Decrypt(src []byte) []byte
}

func NewAESCFB

func NewAESCFB(key, iv []byte) BlockCryptor

key should be 16, 24, or 32 bytes

func NewCrypt

func NewCrypt(name string, key, iv []byte) BlockCryptor

func NewNoneCrypt

func NewNoneCrypt(key, iv []byte) BlockCryptor

func NewSM4

func NewSM4(key, iv []byte) BlockCryptor

key must be 16-byte

func NewSalsa20

func NewSalsa20(key, iv []byte) BlockCryptor

func NewTripleDES

func NewTripleDES(key, iv []byte) BlockCryptor

key must be 24-byte

func NewTwofish

func NewTwofish(key, iv []byte) BlockCryptor

key should be 16, 24 or 32 bytes

func NewXTEA

func NewXTEA(key, iv []byte) BlockCryptor

key must be 16 bytes

Jump to

Keyboard shortcuts

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