v0.2.0 Latest Latest

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

Go to latest
Published: Feb 26, 2019 License: Apache-2.0 Imports: 8 Imported by: 0



cipher package is a helper package for encrypting and decrypting messages



This section is empty.


This section is empty.


func GeneratePrivateKey

func GeneratePrivateKey(size int) *rsa.PrivateKey

GeneratePrivateKey will create a private key with the size given size must be greater than 64 or else it will default to 64.

Careful with the size, if its too large it won't encrypt the message or take forever


type Crypt

type Crypt interface {
	// EncryptMessage attempts to encode the message into an array of bytes.
	// and error will be returned if failed to encode the message.
	EncryptMessage(message []byte) ([]byte, error)

	// DecryptMessage attempts to decode the message into a string.
	// and error will be returned if failed to decode the message.
	DecryptMessage(cipher []byte) ([]byte, error)

Crypt represents the ability to encrypt and decrypt messages

type Interface

type Interface interface {

I the Interface for cipher to encrypt decrypt and verify the message

func NewCrypter

func NewCrypter(hash crypto.Hash, key *rsa.PrivateKey) Interface

type NOOP

type NOOP struct{}

NOOP will just return the message

func (*NOOP) DecryptMessage

func (noop *NOOP) DecryptMessage(cipher []byte) ([]byte, error)

func (*NOOP) EncryptMessage

func (noop *NOOP) EncryptMessage(message []byte) ([]byte, error)

func (*NOOP) Sign

func (noop *NOOP) Sign(message []byte) ([]byte, error)

func (*NOOP) VerifyMessage

func (noop *NOOP) VerifyMessage(message []byte, signature []byte) bool

type Verify

type Verify interface {
	// Sign attempts to sign the message into an array of bytes
	// and an error will be returned if a failure is encountered while signing the message.
	Sign(message []byte) ([]byte, error)

	// VerifyMessage will return true if the message was successfully verified
	VerifyMessage(message []byte, signature []byte) bool

Verify is used to sign and verify the signature of a message

Jump to

Keyboard shortcuts

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