Last active
April 14, 2017 07:57
-
-
Save alibitek/159c8be7ef21143104da07661ce3dcb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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