This commit is contained in:
kkb0318
2024-03-28 22:18:54 +09:00
parent bd650cadea
commit 476746b036
3 changed files with 36 additions and 12 deletions
+11 -3
View File
@@ -8,11 +8,11 @@ import (
)
type KeyPair struct {
PublicKey []byte
PrivateKey []byte
publicKey []byte
privateKey []byte
}
func createKeyPair() (*KeyPair, error) {
func CreateKeyPair() (*KeyPair, error) {
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
return nil, err
@@ -38,3 +38,11 @@ func createKeyPair() (*KeyPair, error) {
pubPemBytes := pem.EncodeToMemory(&pubPem)
return &KeyPair{pubPemBytes, privPemBytes}, nil
}
func (k *KeyPair) PublicKey() []byte {
return k.publicKey
}
func (k *KeyPair) PrivateKey() []byte {
return k.privateKey
}