Skip to content

Commit e336918

Browse files
committed
add more examples to documentation
1 parent 809a282 commit e336918

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

README.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ openssl rsa -in private.pem -out public.pem -pubout -outform PEM
1717
```go
1818
package main
1919

20-
import (
21-
"fmt"
22-
"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib"
23-
)
24-
2520
const (
2621
testPrivateKey = `-----BEGIN RSA PRIVATE KEY-----
2722
MIIEowIBAAKCAQEAxGDcSAjiHKP9v2ITR+BjQmt9Tx2zW08ZyrjOxPew+Gxl2m5z
@@ -63,6 +58,7 @@ bQIDAQAB
6358
`
6459
)
6560
```
61+
6662
```go
6763
package main
6864

@@ -143,4 +139,40 @@ func rsaEncryptDecryptAndBase64Encode() {
143139
}
144140
```
145141

142+
```go
143+
package main
144+
145+
import (
146+
"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib"
147+
"log"
148+
)
149+
150+
func encodeDecodeWithBase85() {
151+
expectedText := "foo"
152+
encodedText := cryptolib.Encoder{}.ToBase85([]byte(expectedText))
153+
actualText := string(cryptolib.Decoder{}.FromBase85(encodedText))
154+
if actualText != expectedText {
155+
log.Fatal("failed to decode")
156+
}
157+
}
158+
```
159+
160+
```go
161+
package main
162+
163+
import (
164+
"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib"
165+
"log"
166+
)
167+
168+
func encodeDecodeWithBase64() {
169+
expectedText := "foo"
170+
encodedText := cryptolib.Encoder{}.ToBase64([]byte(expectedText))
171+
actualText := string(cryptolib.Decoder{}.FromBase64(encodedText))
172+
if actualText != expectedText {
173+
log.Fatal("failed to decode")
174+
}
175+
}
176+
```
177+
146178
**NOTE**: please refer to [rsa-encrypt-decrypt-python](https://github.com/vspaz/rsa-encrypt-decrypt-python) if you need the Python lib.

0 commit comments

Comments
 (0)