-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsa_key.go
More file actions
39 lines (32 loc) · 793 Bytes
/
rsa_key.go
File metadata and controls
39 lines (32 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2024 FishGoddess. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"github.com/FishGoddess/cryptox/rsa"
)
func main() {
// Generate a 2048 bits key.
privateKey, publicKey, err := rsa.GenerateKeys(2048)
if err != nil {
panic(err)
}
// Store the private key and the public key to file.
err = rsa.StorePrivateKey("rsa.key", privateKey)
if err != nil {
panic(err)
}
err = rsa.StorePublicKey("rsa.pub", publicKey)
if err != nil {
panic(err)
}
// Load the private key and the public key from file.
privateKey, err = rsa.LoadPrivateKey("rsa.key")
if err != nil {
panic(err)
}
publicKey, err = rsa.LoadPublicKey("rsa.pub")
if err != nil {
panic(err)
}
}