更换基础镜像
This commit is contained in:
@@ -79,6 +79,10 @@
|
||||
<a href="#" name="tab_main">主密钥分散</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" name="tab_main_comp">主密钥合成</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" name="tab_file">文件操作</a>
|
||||
</li>
|
||||
@@ -138,6 +142,26 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab tab_main_comp" style="display: none">
|
||||
|
||||
<div style="margin: 3rem 0">
|
||||
<span id="show_m1" style="display: none">[分量1已录入]</span>
|
||||
<button id="btn_loadm1" style="margin-right: 1rem">读取分量1</button>
|
||||
<span id="show_m2" style="display: none">[分量2已录入]</span>
|
||||
<button id="btn_loadm2" style="margin-right: 1rem">写入分量2</button>
|
||||
<span id="show_m3" style="display: none">[分量3已录入]</span>
|
||||
<button id="btn_loadm3" style="margin-right: 1rem">写入分量3</button>
|
||||
</div>
|
||||
|
||||
<div class="form" id="mainkey_out" style="display: none">
|
||||
<p>
|
||||
<span>主密钥已合成,</span><button id="mainkey_comp_show" onclick="downloadMainKey()">点我下载</button><span>!</span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="tab tab_file" style="display: none">
|
||||
|
||||
@@ -567,6 +591,129 @@
|
||||
|
||||
</script>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
function publicRead(filepath) {
|
||||
let txt = ''
|
||||
try {
|
||||
const idx = filepath.lastIndexOf("\\")
|
||||
const folder = filepath.substr(0, idx)
|
||||
const file = filepath.substr(idx + 1)
|
||||
txt = window.UKey.readFile(folder, file);
|
||||
return txt.data;
|
||||
} catch (e) {
|
||||
alert("读取失败:" + e.message)
|
||||
}
|
||||
return txt
|
||||
}
|
||||
|
||||
|
||||
function readKey( p ){
|
||||
var role = publicRead('\\root\\mana\\a20')
|
||||
console.log("role", role);
|
||||
if ( role != p ) {
|
||||
alert("分量编号错误")
|
||||
return
|
||||
}
|
||||
|
||||
if ( ! window.mk ) {
|
||||
window.mk = {}
|
||||
}
|
||||
|
||||
if ( 31 == p ) {
|
||||
window.mk.weight0x30 = publicRead('\\root\\mana\\a30')
|
||||
window.mk.weight0x40 = publicRead('\\root\\mana\\a40')
|
||||
window.mk.weight0x401 = publicRead('\\root\\mana\\a40')
|
||||
window.mk.weight0x50 = publicRead('\\root\\mana\\a50')
|
||||
window.mk.weight0x60 = publicRead('\\root\\mana\\a60')
|
||||
window.mk.weight0x601 = publicRead('\\root\\mana\\a60')
|
||||
} else if ( 32 == p ) {
|
||||
window.mk.weight0x402 = publicRead('\\root\\mana\\a40')
|
||||
window.mk.weight0x602 = publicRead('\\root\\mana\\a60')
|
||||
} else if ( 33 == p ) {
|
||||
|
||||
window.mk.weight0x403 = publicRead('\\root\\mana\\a40')
|
||||
window.mk.weight0x603 = publicRead('\\root\\mana\\a60')
|
||||
|
||||
} else {
|
||||
alert("分量编号错误")
|
||||
}
|
||||
|
||||
// 每次都执行
|
||||
$("#btn_loadm" + ( p - 30 )).hide()
|
||||
$("#show_m" + ( p - 30 )).show()
|
||||
|
||||
// 全部结束后执行
|
||||
if ( window.mk.weight0x601 && window.mk.weight0x602 && window.mk.weight0x603 ) {
|
||||
var mk = checkValue( window.mk.weight0x601, window.mk.weight0x602, window.mk.weight0x603 )
|
||||
if ( mk ) {
|
||||
$("#mainkey_out").show();
|
||||
window.mkd = mk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("#btn_loadm1").click(function (){
|
||||
readKey( 31 )
|
||||
})
|
||||
|
||||
$("#btn_loadm2").click(function (){
|
||||
readKey( 32 )
|
||||
})
|
||||
|
||||
$("#btn_loadm3").click(function (){
|
||||
readKey( 33 )
|
||||
})
|
||||
|
||||
// 将十六进制字符串转换为二进制数组
|
||||
function hexToBytes(hex) {
|
||||
const bytes = new Uint8Array(hex.length / 2);
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
function downloadMainKey(){
|
||||
|
||||
// 创建一个Blob对象
|
||||
const bytes = hexToBytes(window.mkd);
|
||||
const blob = new Blob([bytes], { type: 'application/octet-stream' });
|
||||
|
||||
// 生成一个临时的URL
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
|
||||
// 创建一个a标签并设置为下载链接
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.href = blobUrl;
|
||||
downloadLink.download = 'MainKey.Dat'; // 指定下载文件的名称
|
||||
|
||||
// 触发a标签的点击事件以开始下载
|
||||
document.body.appendChild(downloadLink);
|
||||
downloadLink.click();
|
||||
document.body.removeChild(downloadLink);
|
||||
|
||||
// 清理URL
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
}
|
||||
|
||||
function checkValue(p1, p2, p3){
|
||||
const protectKey = window.gmhelper.xor(p1, p2, p3)
|
||||
const protectKcv = window.gmhelper.kcv( protectKey )
|
||||
if ( protectKcv.toUpperCase().substr(0, 8) != window.mk.weight0x50.toUpperCase()) {
|
||||
alert('保护密钥校验值错误!!!')
|
||||
return false
|
||||
}
|
||||
var finalMainKey = window.gmhelper.decryptKey(window.mk.weight0x40 , protectKey) // 解密
|
||||
const mainKcv = window.gmhelper.kcv( finalMainKey )
|
||||
if ( mainKcv.toUpperCase().substr(0, 8) !== window.mk.weight0x30.toUpperCase()) {
|
||||
alert('主密钥校验值错误!!!')
|
||||
return false
|
||||
}
|
||||
return finalMainKey;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user