本文整理匯總了TypeScript中node-forge.ssh類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ssh類的具體用法?TypeScript ssh怎麽用?TypeScript ssh使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ssh類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: generateKeyPair
export function generateKeyPair(): KeyPair {
const pair = forge.pki.rsa.generateKeyPair({bits: 1538});
// trim() the string because forge adds a trailing space to
// public keys which really messes things up later.
return {
public: forge.ssh.publicKeyToOpenSSH(pair.publicKey, '').trim(),
private: forge.ssh.privateKeyToOpenSSH(pair.privateKey, '').trim()
};
}
示例2:
import * as forge from 'node-forge';
let keypair = forge.pki.rsa.generateKeyPair({ bits: 512 });
let privateKeyPem = forge.pki.privateKeyToPem(keypair.privateKey);
let publicKeyPem = forge.pki.publicKeyToPem(keypair.publicKey);
let key = forge.pki.decryptRsaPrivateKey(privateKeyPem);
let x: string = forge.ssh.privateKeyToOpenSSH(key);
let pemKey: forge.pki.PEM = publicKeyPem;
let publicKeyRsa = forge.pki.publicKeyFromPem(pemKey);
let privateKeyRsa = forge.pki.privateKeyFromPem(privateKeyPem);
let byteBufferString = forge.pki.pemToDer(privateKeyPem);
let cert = forge.pki.createCertificate();
{
let subjectPublicKeyInfo = forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.SEQUENCE, true, [
forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.SEQUENCE, true, [
forge.asn1.create(
forge.asn1.Class.UNIVERSAL,
forge.asn1.Type.OID,
false,
forge.asn1.oidToDer(forge.pki.oids['rsaEncryption']).getBytes()
),
forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.NULL, false, '')
]),
forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.BITSTRING, false, [
forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.SEQUENCE, true, [
forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.INTEGER, false, []),
forge.asn1.create(forge.asn1.Class.UNIVERSAL, forge.asn1.Type.INTEGER, false, [])
])
])
]);