Skip to content

Instantly share code, notes, and snippets.

@emindeniz99
Last active December 31, 2021 06:54
Show Gist options
  • Save emindeniz99/d2958e17a95abc05d80e4f548c2a8e12 to your computer and use it in GitHub Desktop.
Save emindeniz99/d2958e17a95abc05d80e4f548c2a8e12 to your computer and use it in GitHub Desktop.
public website with encrypted phone number

idea

add a personal info to my personal website

but i want it to be accessible with only some key

I write this url to my NFC card, so I can easily share my phone number with people

https://emindeniz99.com/#1234567890123456 shows my phone number if the hash part is correct

<!--!!!RENDERHTML-->
<!-- notion.so - nextjs renderer page, my custom html block -->
<a id="phone-enc"
target="_blank" rel="noopener noreferrer" class="notion-link"
href=""></a>
<script>
(async () => {
let pwd = window.location.hash.slice(1)
let a = document.getElementById("phone-enc")
a.parentElement.style="display:none;"
if (!pwd) return;
let encccc = new Uint8Array([187, .......1])
let buff = await ((async (text, pw) => {
let enc = new TextEncoder();
let keyy = await window.crypto.subtle.importKey(
"raw",
enc.encode(pw)
,
"AES-CTR",
true,
["encrypt", "decrypt"]
);
let a = await window.crypto.subtle.encrypt(
{
name: "AES-CTR",
counter: enc.encode(pw),
length: 64
},
keyy,
text
);
let dec = new TextDecoder();
return dec.decode(a)
})(encccc, pwd));
buff;
if (buff.includes("tel:")) {
let a = document.getElementById("phone-enc")
a.parentElement.style = ""
a.parentElement.className = "notion-blue_background"
a.innerText = buff.slice(4)
a.href = buff
}
})();
</script>
let pwd="1234567890123456" // 16 char length
let pwd=window.location.hash.slice(1) // it fetch the hash at URL
let buff=await ((async (text,pw)=>{
let enc = new TextEncoder();
let keyy=await window.crypto.subtle.importKey(
"raw",
enc.encode(pw)
,
"AES-CTR",
true,
["encrypt", "decrypt"]
);
let a= await window.crypto.subtle.encrypt(
{
name: "AES-CTR",
counter:enc.encode(pw),
length: 64
},
keyy,
enc.encode(text)
);
return a
})("tel:+90....your phonenumber",pwd));
buff;
new Uint8Array(buff);
//decrypt
let pwd=window.location.hash.slice(1)
let buff=await ((async (text,pw)=>{
let enc = new TextEncoder();
let keyy=await window.crypto.subtle.importKey(
"raw",
enc.encode(pw)
,
"AES-CTR",
true,
["encrypt", "decrypt"]
);
let a= await window.crypto.subtle.encrypt(
{
name: "AES-CTR",
counter:enc.encode(pw),
length: 64
},
keyy,
text
);
let dec = new TextDecoder();
return dec.decode(a)
})(new Uint8Array([187, 3, ....... your array from encryption]),pwd));
buff;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment