display pubkey in PEM format instead of hex for peers
This commit is contained in:
parent
cfebb76398
commit
4b616772cc
@ -25,7 +25,7 @@ function render_room(roomId, pubkey) {
|
||||
|
||||
// public key textarea
|
||||
const pubKeyText = document.createElement('textarea');
|
||||
pubKeyText.value = pubkey;
|
||||
pubKeyText.value = hexToPem(pubkey);
|
||||
pubKeyText.readOnly = true;
|
||||
roomDiv.appendChild(pubKeyText);
|
||||
|
||||
@ -117,4 +117,12 @@ async function request_rooms() {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
function hexToPem(hexString) {
|
||||
const byteArray = new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
let base64 = btoa(String.fromCharCode.apply(null, byteArray));
|
||||
const base64Chunks = base64.match(/.{1,64}/g) || [];
|
||||
return `-----BEGIN PUBLIC KEY-----\n${base64Chunks.join('\n')}\n-----END PUBLIC KEY-----`;
|
||||
}
|
||||
|
||||
|
||||
export { render_room, render_rooms_wrapper };
|
||||
|
Loading…
x
Reference in New Issue
Block a user