mirror of
https://git.numenor-labs.us/dsfx.git
synced 2025-04-29 16:20:34 +00:00
32 lines
472 B
Go
32 lines
472 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"crypto/x509"
|
||
|
"encoding/pem"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"koti.casa/numenor-labs/dsfx/shared/dcrypto"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
key, err := dcrypto.GenerateSigningKey()
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
// Encode the private key to der
|
||
|
der, err := x509.MarshalECPrivateKey(key)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
// Encode the private key to PEM
|
||
|
pem := pem.EncodeToMemory(&pem.Block{
|
||
|
Type: "PRIVATE KEY",
|
||
|
Bytes: der,
|
||
|
})
|
||
|
|
||
|
fmt.Fprint(os.Stdout, string(pem))
|
||
|
}
|