File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2024 Tim Cocks
2
+ # SPDX-License-Identifier: MIT
3
+ """
4
+ This script can be used to generate a new key pair and output them as JSON.
5
+ You can copy the JSON from serial console and paste it into a new file
6
+ on the device and then use it with the rsa_json_keys.py example.
7
+ """
8
+ import json
9
+ import adafruit_rsa
10
+
11
+
12
+ # Create a keypair
13
+ print ("Generating keypair..." )
14
+ (public_key , private_key ) = adafruit_rsa .newkeys (512 )
15
+
16
+
17
+ print ("public json:" )
18
+ print ("-------------------------------" )
19
+ public_obj = {"public_key_arguments" : [public_key .n , public_key .e ]}
20
+ print (json .dumps (public_obj ))
21
+ print ("-------------------------------" )
22
+
23
+
24
+ print ("private json:" )
25
+ print ("-------------------------------" )
26
+ private_obj = {
27
+ "private_key_arguments" : [
28
+ private_key .n ,
29
+ private_key .e ,
30
+ private_key .d ,
31
+ private_key .p ,
32
+ private_key .q ,
33
+ ]
34
+ }
35
+ print (json .dumps (private_obj ))
36
+ print ("-------------------------------" )
You can’t perform that action at this time.
0 commit comments