rsa

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 5 Imported by: 1

README

RSA Key Generator

RSA Key Generator is a Go package that provides a simple way to generate RSA key pairs.

Installation

go get github.com/nlgolib/rsa

Functionality Highlights

  • Generate RSA key pairs with different bit sizes
  • Generate RSA key pairs with 4096, 2048, and 1024 bits
  • Initialize RSA key pairs from PEM encoded strings
  • Get the PEM encoded public and private keys

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKeyPair

func NewKeyPair(bits int) (*PrivateKey, *PublicKey, error)

NewKeyPair creates a new RSA private key with the given number of bits. Minimum bit size is 1024 and must be a multiple of 8.

func NewKeyPair1024

func NewKeyPair1024() (*PrivateKey, *PublicKey, error)

NewKeyPair1024 creates a new RSA private key with 1024 bits.

func NewKeyPair2048

func NewKeyPair2048() (*PrivateKey, *PublicKey, error)

NewKeyPair2048 creates a new RSA private key with 2048 bits.

func NewKeyPair4096

func NewKeyPair4096() (*PrivateKey, *PublicKey, error)

NewKeyPair4096 creates a new RSA private key with 4096 bits.

Types

type PrivateKey

type PrivateKey struct {
	RawKey *rsa.PrivateKey
}

RSA Private Key

func NewPrivateFromPEM

func NewPrivateFromPEM(pemStr string) (*PrivateKey, error)

NewPrivateFromPEM creates a new private key from a PEM encoded string

func (*PrivateKey) BitsSize

func (k *PrivateKey) BitsSize() int

BitsSize returns the size of the private key in bits

func (*PrivateKey) BytesSize

func (k *PrivateKey) BytesSize() int

BytesSize returns the size of the private key in bytes

func (*PrivateKey) PEM

func (k *PrivateKey) PEM() string

PEM returns the PEM encoded private key

func (*PrivateKey) Public

func (k *PrivateKey) Public() *PublicKey

Public returns the public key

type PublicKey

type PublicKey struct {
	RawKey *rsa.PublicKey
}

func NewPublicFromPEM

func NewPublicFromPEM(pemStr string) (*PublicKey, error)

NewPublicFromPEM creates a new public key from a PEM encoded string

func (*PublicKey) BitsSize

func (k *PublicKey) BitsSize() int

BitsSize returns the size of the public key in bits

func (*PublicKey) BytesSize

func (k *PublicKey) BytesSize() int

BytesSize returns the size of the public key in bytes

func (*PublicKey) PEM

func (k *PublicKey) PEM() string

PEM returns the PEM encoded public key

Jump to

Keyboard shortcuts

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