board now uses sha256
This commit is contained in:
parent
24d682860f
commit
71c9337ab7
6 changed files with 16 additions and 8 deletions
|
@ -97,7 +97,9 @@ function appendMessages(msg, blockHash, beforeHash){
|
|||
div[3].textContent = msg['meta']['signer'].substr(0, 5)
|
||||
setHumanReadableIDOnPost(div[3], msg['meta']['signer'])
|
||||
div[3].title = msg['meta']['signer']
|
||||
identicon[0].src = "data:image/svg+xml;base64," + userIcon(msg['meta']['signer'])
|
||||
userIcon(msg['meta']['signer']).then(function(data){
|
||||
identicon[0].src = "data:image/svg+xml;base64," + data
|
||||
})
|
||||
}
|
||||
else{
|
||||
identicon[0].remove()
|
||||
|
|
|
@ -7,8 +7,13 @@ function toHexString(byteArray) {
|
|||
return s;
|
||||
}
|
||||
|
||||
function userIcon(pubkey, imgSize=64){
|
||||
pubkey = toHexString(base32.decode.asBytes(pubkey))
|
||||
async function sha256(str) {
|
||||
const buf = await crypto.subtle.digest("SHA-256", new TextEncoder("utf-8").encode(str));
|
||||
return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join('');
|
||||
}
|
||||
|
||||
async function userIcon(pubkey, imgSize=64){
|
||||
pubkey = await sha256(base32.decode.asBytes(pubkey))
|
||||
let options = {
|
||||
//foreground: [0,0,0,1], // rgba black
|
||||
background: [255, 255, 255, 255], // rgba white
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue