File tree Expand file tree Collapse file tree 9 files changed +673
-24
lines changed Expand file tree Collapse file tree 9 files changed +673
-24
lines changed Original file line number Diff line number Diff line change 1
- # Go project template
1
+ # RSA
2
2
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 )
8
8
9
- Simple golang project template .
9
+ RSA encryption & decryption .
10
10
11
11
## Prerequisite
12
12
Original file line number Diff line number Diff line change
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
+ )
Original file line number Diff line number Diff line change 1
- module github.com/hyperjiang/gotpl
1
+ module github.com/hyperjiang/rsa
2
2
3
3
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
+ )
Original file line number Diff line number Diff line change
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 =
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments