aboutsummaryrefslogtreecommitdiff
path: root/tools/pubkey.go
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-08-15 15:48:19 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-08-15 15:50:32 -0300
commit8082c228c5d618e6f865f76b4d0518c2fde573ec (patch)
tree59e61abe98c3060fb1eb3677b9dbbb744c92174a /tools/pubkey.go
parente4b8bf807b76f6f446d9617d9a3957dc77dd6e90 (diff)
downloadgame-8082c228c5d618e6f865f76b4d0518c2fde573ec.tar.gz
game-8082c228c5d618e6f865f76b4d0518c2fde573ec.zip
wrapping up for a public release
Diffstat (limited to 'tools/pubkey.go')
-rw-r--r--tools/pubkey.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/pubkey.go b/tools/pubkey.go
new file mode 100644
index 0000000..4649664
--- /dev/null
+++ b/tools/pubkey.go
@@ -0,0 +1,34 @@
+package main
+
+import (
+ "crypto/x509"
+ "encoding/pem"
+ "fmt"
+ "log"
+ "os"
+)
+
+func main() {
+ keyFile := "key.pem"
+ if len(os.Args) > 1 {
+ keyFile = os.Args[1]
+ }
+
+ keyData, err := os.ReadFile(keyFile)
+ if err != nil {
+ log.Panicf("failed to read key \"%v\": %v", keyFile, err)
+ }
+
+ keyBlock, _ := pem.Decode(keyData)
+ if keyBlock == nil {
+ log.Panicf("key \"%v\" is empty")
+ }
+
+ privateKey, err := x509.ParsePKCS1PrivateKey(keyBlock.Bytes)
+ if err != nil {
+ log.Panic("failed to read PKCS1 RSA private key: %v", err)
+ }
+
+ fmt.Println("N", privateKey.N)
+ fmt.Println("E", privateKey.E)
+}