Last active
February 10, 2020 10:39
-
-
Save OrderAndCh4oS/e845e6cb868852da137d69315e64726a to your computer and use it in GitHub Desktop.
This file contains 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
function chunkPublicKey(key) { | |
const start = '-----BEGIN PUBLIC KEY-----'; | |
const end = '-----END PUBLIC KEY-----'; | |
const result = []; | |
try { | |
const arr = key.split(''); | |
while(arr.length) { | |
result.push(arr.splice(0, 64).join('')); | |
} | |
} catch(e) { | |
console.log('Error chunking key', e); | |
} | |
return `${start}\n\n${result.join('\n')}\n\n${end}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment