crypto

package
v0.0.0-...-1a912f8 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PrivateKey       *rsa.PrivateKey
	EncodedPublicKey []byte
	JWKPublicKey     JWKkey
)
View Source
var (
	Cert *tls.Certificate = nil
)

Functions

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) *rsa.PrivateKey

func BytesToPublicKey

func BytesToPublicKey(pub []byte) *rsa.PublicKey

func Decrypt

func Decrypt(ciphered []byte, priv *rsa.PrivateKey) ([]byte, error)

func DecryptAES

func DecryptAES(key, ciphered, iv []byte) (decoded []byte, err error)

func DecryptMessage

func DecryptMessage(Key, IV, Data string) (string, error)

func Encrypt

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

func EncryptAES

func EncryptAES(key []byte, data []byte) (ciphered, nonce []byte)

func GenerateKeys

func GenerateKeys()

func InitCert

func InitCert()

func RsaPublicKeyByModulusAndExponent

func RsaPublicKeyByModulusAndExponent(nStr string, eStr string) *rsa.PublicKey

func Test

func Test()

Types

type EncryptedMessage

type EncryptedMessage struct {
	Data string `json:"Data"`
	Key  string `json:"Key"`
	IV   string `json:"IV"`
}

func EncryptMessage

func EncryptMessage(data []byte, key *rsa.PublicKey) (answer EncryptedMessage, err error)

type JWKkey

type JWKkey struct {
	Kty string `json:"kty"`
	E   string `json:"e"`
	N   string `json:"n"`
}

Jump to

Keyboard shortcuts

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