Created
April 19, 2025 11:44
-
-
Save daveio/ea801cc84715a973a8be98df4923b7fa 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
| const detectKeyType = (key: string): KeyType => { | |
| if (!key.trim()) return null; | |
| if ( | |
| key.includes("-----BEGIN PRIVATE KEY-----") || | |
| key.includes("-----BEGIN RSA PRIVATE KEY-----") || | |
| key.includes("-----BEGIN EC PRIVATE KEY-----") | |
| ) { | |
| return "PKCS#8"; | |
| } else if (key.includes("-----BEGIN OPENSSH PRIVATE KEY-----")) { | |
| return "SSH"; | |
| } else { | |
| return "Unknown"; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment