本文整理匯總了TypeScript中node-forge.asn1.toDer方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript asn1.toDer方法的具體用法?TypeScript asn1.toDer怎麽用?TypeScript asn1.toDer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類node-forge.asn1
的用法示例。
在下文中一共展示了asn1.toDer方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: fingerprint
fingerprint(hash: "sha1" | "sha256" | "sha384" | "sha512" | "md5" = "sha1"): string {
let md: any;
const forgeCSR = forge.pki.certificateFromPem(this._pem, true, true);
switch (hash) {
case "sha1":
md = forge.md.sha1.create();
break;
case "sha256":
md = forge.md.sha256.create();
break;
case "sha384":
md = forge.md.sha384.create();
break;
case "sha512":
md = forge.md.sha512.create();
break;
case "md5":
md = forge.md.md5.create();
break;
default:
throw new Error(`Unrecognized message digest hash algorithm: ${hash}`);
}
const result = md
.update(forge.asn1.toDer(forge.pki.certificateToAsn1(forgeCSR)).getBytes())
.digest()
.toHex();
return result;
}
示例2:
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, [])
])
])
]);
let derBuffer = forge.asn1.toDer(subjectPublicKeyInfo);
let object = forge.asn1.fromDer(derBuffer);
}
{
let oidSrc = '1.2.840.113549.1.1.5';
let derOidBuffer = forge.asn1.oidToDer(oidSrc);
let oidResult = forge.asn1.derToOid(derOidBuffer);
if (oidSrc !== oidResult) throw Error('forge.asn1.oidToDer / derToOid fail');
}
if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillString fail');
{
let hex: string = '61';
let bytes: string = forge.util.hexToBytes(hex);