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.

Revisions

  1. emindeniz99 revised this gist Dec 31, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    ## 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
  2. emindeniz99 renamed this gist Dec 31, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion notionso-block.html → phone-block.html
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    <!--!!!RENDERHTML-->

    <!-- notion.so - nextjs renderer page, my custom html block -->
    <a id="phone-enc"
    target="_blank" rel="noopener noreferrer" class="notion-link"
    href=""></a>
  3. emindeniz99 created this gist Dec 31, 2021.
    60 changes: 60 additions & 0 deletions notionso-block.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    <!--!!!RENDERHTML-->

    <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>

    7 changes: 7 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ## 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

    79 changes: 79 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    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;