I have two files that represent the same DER format public key. They both look like this when I look at them in a text editor (sublime)
3081 9f30 0d06 092a 8648 86f7 0d01 0101 0500 0381 8d00 3081 8902 8181 00d2 d475 9de6 d795 7d0f e5e8 375f 3605 7e06 e391 83e7 58b2 3e46 d4e8 da3e 0ac5 136c fff2 2d0e 8386 af7c 6347 a3fd 4c39 1989 7764 69b1 85e1 f5cc fe3f 4957 c110 4264 f112 ad8f e1b9 c108 cf5e 9a77 8d6c 60b2 150a 954f 725f 25c7 b720 e536 ca81 9686 fe71 4e86 1822 48a9 df17 6c95 f9ed 8e9b a674 1a9f 868d 92a9 d2a5 5721 6dd9 1f02 0301 0001
but one works with RSA.importKey() and one gives me the error "ValueError: RSA key format is not supported”.
When I read them in to python using "key = open('pub.der', "r").read()”
and then print out key, the file that works prints out as:
'0\x81\x9f0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x81\x8d\x000\x81\x89\x02\x81\x81\x00\xd2\xd4u\x9d\xe6\xd7\x95}\x0f\xe5\xe87_6\x05~\x06\xe3\x91\x83\xe7X\xb2>F\xd4\xe8\xda>\n\xc5\x13l\xff\xf2-\x0e\x83\x86\xaf|cG\xa3\xfdL9\x19\x89wdi\xb1\x85\xe1\xf5\xcc\xfe?IW\xc1\x10Bd\xf1\x12\xad\x8f\xe1\xb9\xc1\x08\xcf^\x9aw\x8dl`\xb2\x15\n\x95Or_%\xc7\xb7 \xe56\xca\x81\x96\x86\xfeqN\x86\x18"H\xa9\xdf\x17l\x95\xf9\xed\x8e\x9b\xa6t\x1a\x9f\x86\x8d\x92\xa9\xd2\xa5W!m\xd9\x1f\x02\x03\x01\x00\x01’
and the file that gives the error prints as:
'3081 9f30 0d06 092a 8648 86f7 0d01 0101\n0500 0381 8d00 3081 8902 8181 00d2 d475\n9de6 d795 7d0f e5e8 375f 3605 7e06 e391\n83e7 58b2 3e46 d4e8 da3e 0ac5 136c fff2\n2d0e 8386 af7c 6347 a3fd 4c39 1989 7764\n69b1 85e1 f5cc fe3f 4957 c110 4264 f112\nad8f e1b9 c108 cf5e 9a77 8d6c 60b2 150a\n954f 725f 25c7 b720 e536 ca81 9686 fe71\n4e86 1822 48a9 df17 6c95 f9ed 8e9b a674\n1a9f 868d 92a9 d2a5 5721 6dd9 1f02 0301\n0001’
I have another public key file for which I only have the corrupted/nonworking version. What is the difference between the two files, and how can I convert the version that does not work with RSA.importKey() into a version that does work with RSA.importKey()?