Skip to content

Commit 74d599c

Browse files
author
Hyper
committed
done
1 parent abb47dd commit 74d599c

File tree

9 files changed

+673
-24
lines changed

9 files changed

+673
-24
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Go project template
1+
# RSA
22

3-
[![GoDoc](https://pkg.go.dev/badge/github.com/hyperjiang/go-tpl)](https://pkg.go.dev/github.com/hyperjiang/go-tpl)
4-
[![CI](https://github.com/hyperjiang/go-tpl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/hyperjiang/go-tpl/actions/workflows/ci.yml)
5-
[![](https://goreportcard.com/badge/github.com/hyperjiang/go-tpl)](https://goreportcard.com/report/github.com/hyperjiang/go-tpl)
6-
[![codecov](https://codecov.io/gh/hyperjiang/go-tpl/branch/main/graph/badge.svg)](https://codecov.io/gh/hyperjiang/go-tpl)
7-
[![Release](https://img.shields.io/github/release/hyperjiang/go-tpl.svg)](https://github.com/hyperjiang/go-tpl/releases)
3+
[![GoDoc](https://pkg.go.dev/badge/github.com/hyperjiang/rsa)](https://pkg.go.dev/github.com/hyperjiang/rsa)
4+
[![CI](https://github.com/hyperjiang/rsa/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/hyperjiang/rsa/actions/workflows/ci.yml)
5+
[![](https://goreportcard.com/badge/github.com/hyperjiang/rsa)](https://goreportcard.com/report/github.com/hyperjiang/rsa)
6+
[![codecov](https://codecov.io/gh/hyperjiang/rsa/branch/main/graph/badge.svg)](https://codecov.io/gh/hyperjiang/rsa)
7+
[![Release](https://img.shields.io/github/release/hyperjiang/rsa.svg)](https://github.com/hyperjiang/rsa/releases)
88

9-
Simple golang project template.
9+
RSA encryption & decryption.
1010

1111
## Prerequisite
1212

def.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package rsa
2+
3+
import "fmt"
4+
5+
// KeyFormat defines key format enum type.
6+
type KeyFormat string
7+
8+
// key format constants.
9+
const (
10+
PKCS1 KeyFormat = "pkcs1"
11+
PKCS8 KeyFormat = "pkcs8"
12+
13+
PKCS1PublicKey = "RSA PUBLIC KEY"
14+
PKCS1PrivateKey = "RSA PRIVATE KEY"
15+
PKCS1PublicHeader = "-----BEGIN RSA PUBLIC KEY-----"
16+
PKCS1PublicTail = "-----END RSA PUBLIC KEY-----"
17+
PKCS1PrivateHeader = "-----BEGIN RSA PRIVATE KEY-----"
18+
PKCS1PrivateTail = "-----END RSA PRIVATE KEY-----"
19+
20+
PKCS8PublicKey = "PUBLIC KEY"
21+
PKCS8PrivateKey = "PRIVATE KEY"
22+
PKCS8PublicHeader = "-----BEGIN PUBLIC KEY-----"
23+
PKCS8PublicTail = "-----END PUBLIC KEY-----"
24+
PKCS8PrivateHeader = "-----BEGIN PRIVATE KEY-----"
25+
PKCS8PrivateTail = "-----END PRIVATE KEY-----"
26+
)
27+
28+
var (
29+
invalidPublicKeyError = func() error {
30+
return fmt.Errorf("invalid public key, please make sure the public key is valid")
31+
}
32+
invalidPrivateKeyError = func() error {
33+
return fmt.Errorf("invalid private key, please make sure the private key is valid")
34+
}
35+
invalidRSAKeyError = func() error {
36+
return fmt.Errorf("invalid rsa key, please make sure the key pair is valid")
37+
}
38+
)

go.mod

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
module github.com/hyperjiang/gotpl
1+
module github.com/hyperjiang/rsa
22

33
go 1.18
4+
5+
require github.com/stretchr/testify v1.9.0
6+
7+
require (
8+
github.com/davecgh/go-spew v1.1.1 // indirect
9+
github.com/pmezard/go-difflib v1.0.0 // indirect
10+
gopkg.in/yaml.v3 v3.0.1 // indirect
11+
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
6+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
7+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
8+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

hello.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

hello_test.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)