key
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
c8be082f53
commit
3721564786
10 changed files with 865 additions and 0 deletions
32
key/key.js
Normal file
32
key/key.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
function hex_char(val)
|
||||
{
|
||||
if (val < 10)
|
||||
return String.fromCharCode(48 + val)
|
||||
if (val < 16)
|
||||
return String.fromCharCode(97 + val - 10)
|
||||
}
|
||||
|
||||
function hex_encode(buf)
|
||||
{
|
||||
str = ""
|
||||
for (let i = 0; i < buf.length; i++) {
|
||||
const c = buf[i]
|
||||
str += hex_char(c >> 4)
|
||||
str += hex_char(c & 0xF)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
function go() {
|
||||
const el = document.querySelector("#damus-key")
|
||||
const hex_el = document.querySelector("#hex-key")
|
||||
|
||||
el.addEventListener("input", () => {
|
||||
const decoded = bech32.decode(el.value)
|
||||
const bytes = fromWords(decoded.words)
|
||||
hex_el.value = hex_encode(bytes)
|
||||
});
|
||||
}
|
||||
|
||||
go()
|
Loading…
Add table
Add a link
Reference in a new issue