This commit is contained in:
吕新雨
2026-02-03 00:41:38 +08:00
parent cc36301638
commit ef7c4e774d

View File

@@ -57,15 +57,14 @@ try {
process.exit(1);
}
// 规范化:去掉末尾的换行/回车(避免少数环境里复制粘贴多一个空行)
let text = buf.toString('utf8').replace(/\r/g, '');
text = text.replace(/\n+$/g, '\n');
if (!text.includes('BEGIN') || !text.includes('PRIVATE KEY')) {
// 重要:按“原始字节”做 base64避免任何编码/换行处理导致私钥内容变化
// 这样工作流解码后能 100% 还原原文件内容
const asText = buf.toString('utf8');
if (!asText.includes('BEGIN') || !asText.includes('PRIVATE KEY')) {
console.error('提示:输入内容看起来不像 SSH 私钥(未检测到 PRIVATE KEY 头部)。仍会继续转换,但请确认输入正确。');
}
const b64 = Buffer.from(text, 'utf8').toString('base64');
const b64 = buf.toString('base64');
if (clipboard) {
if (process.platform !== 'darwin') {