-2
我試圖從'.cer'格式解析數據到純文本,我可以在網站上使用。爲此,this library是適合的,但我不明白如何使用它,也許有人使用它,並可以提供建議?爲網站解析「.cer」格式
File example file, you can load this。
我試圖從'.cer'格式解析數據到純文本,我可以在網站上使用。爲此,this library是適合的,但我不明白如何使用它,也許有人使用它,並可以提供建議?爲網站解析「.cer」格式
File example file, you can load this。
事情是這樣的:
var encoded_string = /* your string */;
var input = ASN1.decode(Base64.unarmor(encoded_string));
訪問屬性,如typeName
和sub
:
function buildJSON(input, output){
Object.assign(output, {
type: input.typeName(),
content: input.content()
});
output.sub = [];
if(input.sub){
for(var sub of input.sub){
var obj = {};
buildJSON(sub, obj)
output.sub.push(obj);
}
}
return output;
}
記住加載所需的腳本,並依次是:
你應該在生產中使用它之前,結合腳本。
看到它在行動:https://jsfiddle.net/DerekL/bgz86cvp/
閱讀文檔:https://github.com/lapo-luchini/asn1js/blob/master/dom.js#L51
您好,歡迎StackOverflow上。請花一些時間閱讀幫助頁面,特別是名爲「我可以問什麼問題?」的部分。和「我應該避免問什麼類型的問題?」。更重要的是,請閱讀Stack Overflow問題清單:https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist。您可能還想了解最小化,完整和可驗證的示例。 – SherylHohman
請在問題中包含相關信息。模糊的鏈接可能會導致各種各樣的東西。 – Gassa