openssl

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 14 Imported by: 0

README

openssl

A openssl tool

Installation

Prerequisites
  • Go >= 1.20

With Go module support, simply add the following import

import "github.com/hugiot/pinecone/openssl"

Demo

package main

import (
	"fmt"
	"github.com/hugiot/pinecone/openssl"
)

func main() {
	fmt.Println(openssl.MD5([]byte("hello world")))
	fmt.Println(openssl.SHA1ToString([]byte("hello world")))
	fmt.Println(openssl.SHA256ToString([]byte("hello world")))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyFormatErr = errors.New("the key format must be PKCS#1 or PKCS#8")
View Source
var PrivateKeyErr = errors.New("private key error")
View Source
var PublicKeyErr = errors.New("public key error")

Functions

func MD5

func MD5(p []byte) []byte

func MD5ToString

func MD5ToString(p []byte) string

func RSADecryptByPrivateKey

func RSADecryptByPrivateKey(key string, data []byte) ([]byte, error)

func RSADecryptByPublicKey

func RSADecryptByPublicKey(key string, data []byte) ([]byte, error)

func RSAEncryptByPrivateKey

func RSAEncryptByPrivateKey(key string, data []byte) (string, error)

func RSAEncryptByPublicKey

func RSAEncryptByPublicKey(key string, data []byte) (string, error)

func RSAGenerateKey

func RSAGenerateKey(bits int, format KeyFormat) (privateKey string, publicKey string, err error)

RSAGenerateKey generate public and private keys in pem format bits: 512、1024、2048、3072、4096 format: PKCS1、PKCS8

func SHA1

func SHA1(p []byte) []byte

func SHA1ToString

func SHA1ToString(p []byte) string

func SHA256

func SHA256(p []byte) []byte

func SHA256ToString

func SHA256ToString(p []byte) string

Types

type KeyFormat

type KeyFormat uint8 // key format
const (
	PKCS1 KeyFormat = iota // PKCS#1
	PKCS8                  // PKCS#8
)

Jump to

Keyboard shortcuts

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