cryptos

package
v0.0.0-...-e73f883 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureECPrivateKeyHeader

func EnsureECPrivateKeyHeader(privKey string) string

func EnsurePrivateKeyHeader

func EnsurePrivateKeyHeader(privKey string) string

func EnsurePublicKeyHeader

func EnsurePublicKeyHeader(pubKey string) string

Types

type AESBase

type AESBase struct{}

func (AESBase) PKCS7Padding

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

func (AESBase) PKCS7UnPadding

func (AESBase) PKCS7UnPadding(origData []byte) []byte

type AESCBC

type AESCBC struct {
	AESBase
	// contains filtered or unexported fields
}

func NewAESCBC

func NewAESCBC(key []byte) AESCBC

Symmetric key length must be a multiple of 16

func NewAESCBCMd5Key

func NewAESCBCMd5Key(key string) AESCBC

Symmetric key length must be a multiple of 16

func (AESCBC) Decrypt

func (s AESCBC) Decrypt(cryptedData []byte) ([]byte, error)

func (AESCBC) DecryptStr

func (s AESCBC) DecryptStr(cryptedData string) (string, error)

func (AESCBC) Encrypt

func (s AESCBC) Encrypt(originalData []byte) ([]byte, error)

func (AESCBC) EncryptStr

func (s AESCBC) EncryptStr(originalData string) (string, error)

type ECC

type ECC struct {
}

Elliptic Curve Cryptography (ECC) is a key-based technique for encrypting data. ECC focuses on pairs of public and private keys for decryption and encryption of web traffic. ECC is frequently discussed in the context of the Rivest–Shamir–Adleman (RSA) cryptographic algorithm. EllipticCurve data struct

func (ECC) DecodePrivate

func (ec ECC) DecodePrivate(pemEncodedPriv string) (privateKey *ecdsa.PrivateKey, err error)

DecodePrivate private key

func (ECC) DecodePublic

func (ec ECC) DecodePublic(pemEncodedPub string) (publicKey *ecdsa.PublicKey, err error)

DecodePublic public key

func (ECC) EncodePrivate

func (ec ECC) EncodePrivate(privKey *ecdsa.PrivateKey) (key string, err error)

EncodePrivate private key

func (ECC) EncodePublic

func (ec ECC) EncodePublic(pubKey *ecdsa.PublicKey) (key string, err error)

EncodePublic public key

func (ECC) GenerateKey

func (ec ECC) GenerateKey(curve elliptic.Curve) (privKey *ecdsa.PrivateKey, err error)

GenerateKeys EllipticCurve public and private keys

func (ECC) GenerateKeyPairPem

func (ec ECC) GenerateKeyPairPem(curve elliptic.Curve) (pubKeyPem string, privKeyPem string, err error)

func (ECC) Sign

func (ec ECC) Sign(privKeyPem string, bs []byte) (signature []byte, err error)

VerifySignature sign ecdsa style and verify signature

func (ECC) Verify

func (ec ECC) Verify(pubKeyPem string, bs []byte, signature []byte) (bool, error)

type EDdSA

type EDdSA struct{}

func (EDdSA) GenerateKeyPairPem

func (EDdSA) GenerateKeyPairPem() (pubKeyPEM string, priKeyPem string, err error)

func (EDdSA) Sign

func (EDdSA) Sign(privKeyPem string, bs []byte) (signature []byte, err error)

func (EDdSA) Verify

func (EDdSA) Verify(pubKeyPem string, bs []byte, signature []byte) (bool, error)

type RSA

type RSA struct{}

func (RSA) GenerateKeyPairPem

func (RSA) GenerateKeyPairPem(bits int) (string, string, error)

func (RSA) OAEPDecrypt

func (RSA) OAEPDecrypt(cipherText string, privKey rsa.PrivateKey) ([]byte, error)

func (RSA) OAEPEncrypt

func (RSA) OAEPEncrypt(secretMessage []byte, key rsa.PublicKey) (string, error)

func (RSA) ParsePrivateKeyFromPEM

func (RSA) ParsePrivateKeyFromPEM(privPEM string) (rsa.PrivateKey, error)

func (RSA) ParsePublicKeyFromPEM

func (RSA) ParsePublicKeyFromPEM(pubPEM string) (rsa.PublicKey, error)

Jump to

Keyboard shortcuts

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