Skip to content

Instantly share code, notes, and snippets.

@alibitek
Last active April 14, 2017 07:57
Show Gist options
  • Save alibitek/159c8be7ef21143104da07661ce3dcb9 to your computer and use it in GitHub Desktop.
Save alibitek/159c8be7ef21143104da07661ce3dcb9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
def chunks(l, n):
""" Yield successive n-sized chunks from l.
"""
for i in range(0, len(l), n):
yield l[i:i+n]
# uncomment as per your usage
#pem_key = '-----BEGIN PUBLIC KEY-----\\n'
#pem_key = '-----BEGIN CERTIFICATE-----\\n'
pem_key = '-----BEGIN PRIVATE KEY-----\\n'
key = 'your certificate or key all in one line without \n'
for chunk in list(chunks(key, 64)):
pem_key += chunk + '\\n'
# uncomment as per your usage
#pem_key += '-----END PUBLIC KEY-----'
#pem_key += '-----END CERTIFICATE-----'
pem_key += '-----END PRIVATE KEY-----'
print(pem_key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment