标签:link UNC -- 代码 cer idv rop nload esb
// 下载方法
downloadString=(name, data) =>{
var urlObject = window.URL || window.webkitURL || window;
var export_blob = new Blob([data]);
var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
save_link.href = urlObject.createObjectURL(export_blob);
save_link.download = name;
fakeClick(save_link);
}
// base64解码
function base64toBlob(base64,type) {
// 将base64转为Unicode规则编码
let bstr = atob(base64, type),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n) // 转换编码后才可以使用charCodeAt 找到Unicode编码
}
return new Blob([u8arr], {
type,
})
}
// 下载函数
downloadCerti =(e) =>{
e.stopPropagation();
const text ={
"raw": "MIIDVzCCAj+gAwIBAgIJAME7VxqDpbFKMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlhYMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1bHQgQ29tcGFueSBMdGQwHhcNMTUxMTE0MTMxMzIyWhcNMjEwNTA2MTMxMzIyWjBCMQswCQYDVQQGEwJYWDEVMBMGA1UEBwwMRGVmYXVsdCBDaXR5MRwwGgYDVQQKDBNEZWZhdWx0IENvbXBhbnkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmfEpGfJiLs22nAvtdANa3Oe8QeeUe1h2L6PBmULgT7r72yOJnmn7+aIDS3pz0dG/0tRDitBT59iZZyR8pGONNUxKMXkWeebq75BwjHFXS0q8FzpuKumXFPreU3YUv3VWZY9daFbdTb2zoOSuIq/R3CTUbBjr3Jo8jMgcU6H+LSPOSnuqyMeMdzukEOLxUdCBPYpSjyVvK+DYlLrMGUUs+qd8Ogj8UIK7NYSzLcfSgbK4iOLECA9wSncHSHKZob4bN18XLO/9ISweLXDZIl7jyiChC751NqkXaMBXS5S8LB89j96oHey+F9PYtwYJF4Mvl/NIO4Qu6rU3Gk6jj7x10QIDAQABo1AwTjAdBgNVHQ4EFgQUwrEp3crjQH/4xgV//knDRht+t4swHwYDVR0jBBgwFoAUwrEp3crjQH/4xgV//knDRht+t4swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAfMJ2autXM20WQkLuFw+6hV5uDiOtxkag9U5UMcK/pDSzUEdsOqxjHrWFye8d5hTM7oTxfWw9STRptLsAf1O5BBciSd/CW02qgE3emp72J4bEYIX/Lo7gBiCruY5SxiiqhdSUBRwof0+49wo1mIxkSouYWb+vE43rQsUMWgQqzTAxNZSDFZtmz8sbiwZIkFib+6VeAueXeAdoU8KSd1lqtB1b8NU8OTMsli4CJh31ODn9wbyp7zuNudKOIYNvaODQ9ac77SpsildkmtZI9/mKsydq4PVHwcG2lqWlPtW2CVfzogl+sFNWzLK13Em1gSM4BsS/+wp7qrefgETJQzh9Mw==",
"cert_sha1": "02f5e6373b0dc0afd8b7e2c9cb7509bcb91c7622"
}
downloadString(text.cert_sha1 + ‘.cer‘,base64toBlob(text.raw)) //JSON.stringify(data)
}
html代码
<Button type="primary" size="small" onClick={event =>this.downloadCerti(event)}>下载证书</Button>
标签:link UNC -- 代码 cer idv rop nload esb
原文地址:https://www.cnblogs.com/aloneindefeat/p/13826917.html