rsa

package
v0.0.0-...-82e7740 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package rsa implements RSA encryption as specified in PKCS#1.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(src, privateKey []byte) ([]byte, error)

Decrypt decrypts the first block in src into dst. Dst and src may point at the same memory.

func DecryptHex

func DecryptHex(src, privateKey string) (string, error)

DecryptHex decrypts the first block in src into dst.

func Encrypt

func Encrypt(src, publicKey []byte) ([]byte, error)

Encrypt encrypts the first block in src into dst. Dst and src may point at the same memory.

func EncryptHex

func EncryptHex(src, publicKey string) (string, error)

EncryptHex encrypts the first block in src into dst.

func GenerateKey

func GenerateKey(bits int) (privateKey []byte, publicKey []byte, err error)

GenerateKey generates an RSA keypair of the given bit size.

func GeneratingKey

func GeneratingKey(bits int) (privateKey string, publicKey string, err error)

GeneratingKey generates an RSA keypair of the given bit size.

Example
package main

import (
	"fmt"
	"strings"

	"gopkg.in/goyy/goyy.v0/util/crypto/rsa"
)

func main() {
	prikey, pubkey, _ := rsa.GeneratingKey(512)
	fmt.Println(strings.Contains(prikey, "-----BEGIN RSA PRIVATE KEY-----"))
	fmt.Println(strings.Contains(pubkey, "-----BEGIN RSA PUBLIC KEY-----"))

}
Output:

true
true

Types

This section is empty.

Jump to

Keyboard shortcuts

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