Skip to content

Instantly share code, notes, and snippets.

@geek-id
Last active July 6, 2018 08:01
Show Gist options
  • Save geek-id/54d6ba211ea8aec8d9e38e2bf861b9ba to your computer and use it in GitHub Desktop.
Save geek-id/54d6ba211ea8aec8d9e38e2bf861b9ba to your computer and use it in GitHub Desktop.
read_copy.py
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAtVYNkkOkn807L7DwLWU8XdoJar2GpE/i29enFGzTgFTEuYDS
mQCs3crfMmFraTjiMMAKqiFz3ONGmoBchbSgITSAnIZgmxq58ok+LQs67weRzwRd
IK+eZefTjqRuJlnhfFU5qmQYDnf4fsttGHdPjljOZAxoL79Xwvg0lPN/5+CmC11e
jYqoR30n0a9Zvp3i6tk1IJZRTM0HTPoKAA03lilGBK42zPcl1bpC/hW0FVdzlc+Y
ckToJ1RmquNCKx7kOy0E4fGD9ETpnCZbFEbQ8IwSCJu2K+qQCXkcEqUOsFT2MBsp
8dZnaeyaB70JTTYhpIm/Lcokr3K9f+SC/ibn7QIDAQABAoIBADn99kMjjN9qRBZh
cL4j1SVymHZhfFDKF5QVKKLYlt9AvNVShIdX9vDLc4vqKe6xuWy7ze1Q23v111uL
14sPE/LqloL4Wqbf6j3NdGv1XniZJCFflOTiJTcT582DepKbRgh8PP/oGOVvqrHq
Hs6nQXMVpZPLf/pdKBT7Sd2k7e/al4aar+SRFBb8UqSjTW1hDLTjJMFJ9mVDXu8I
4CQqCayLeRjV/XjNNAwEMorRLcbEl7b7hoC/OMBajjl/ulGRVI5ahgmFaZBIZA4A
ZFEXBfl+xL13KANH2V/N9ZUtskw+APqQrKXkVYq5r0fnqZQZMxy7U43Xpj9nYYba
uGHnACUCgYEA3IUDL7sgZq1bzywNfPIDmu/58FkL0XJG/gTJdhIUikOxxKbhjAMQ
FHh4JSiQ1DS3a1gIrR90T8ps2Lo4urCVt81/6FJvUMkkFxVIG0xEeq0IQqp84hyx
dYyd779ce8e1/a7NNqfPGjq/metZxlHvHFcp6BdT5z6qi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x8/
wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
-----END CERTIFICATE-----
import re
import os
f = open("/home/geekid/Github/combined")
# f = f.readlines()
key_start = re.compile("-----BEGIN RSA PRIVATE KEY-----")
key_end = re.compile("-----END RSA PRIVATE KEY-----")
# print f
def re_range(f, key_start, key_end) :
for line in f:
if key_start.match(line):
yield line
break
for line in f:
yield line
if key_end.match(line):
break
with f as file:
for line in re_range(file, key_start, key_end):
if not os.path.exists ('/home/geekid/Github/ssl'):
os.makedirs ('/home/geekid/Github/ssl')
if os.path.exists ('/home/geekid/Github/ssl/key_test.txt'):
pass
# # print line,
else :
ssl_key = open ('/home/geekid/Github/ssl/key_test.txt', 'a')
ssl_key.writelines(line)
# ssl_key.write("\n")
ssl_key.close
# ssl_key.close()
# print line,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment