This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const digest = sodium.crypto_generichash(64, sodium.from_string(message)); | |
| const digest_base64 = sodium.to_base64(digest, base64_variants.ORIGINAL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const created = Math.floor(new Date().getTime() / 1000).toString(); | |
| const expires = (parseInt(created) + (1 * 60 * 60)).toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sodium, { base64_variants } from "libsodium-wrappers"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "context": { | |
| "domain": "nic2004:52110", | |
| "action": "search", | |
| "country": "IND", | |
| "city": "std:080", | |
| "core_version": "1.0.0", | |
| "bpp_id": "", | |
| "bpp_uri": "", | |
| "bap_id": "bap_subcriber_id", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| def create_signing_string(digest_base64, created=None, expires=None): | |
| if created is None: | |
| created = int(datetime.datetime.now().timestamp()) | |
| if expires is None: | |
| expires = int((datetime.datetime.now() + datetime.timedelta(hours=1)).timestamp()) | |
| signing_string = f"""(created): {created} | |
| (expires): {expires} | |
| digest: BLAKE-512={digest_base64}""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import nacl.encoding | |
| import nacl.hash | |
| def hash_message(msg: str): | |
| HASHER = nacl.hash.blake2b | |
| digest = HASHER(bytes(msg, 'utf-8'), digest_size=64, encoder=nacl.encoding.Base64Encoder) | |
| digest_str = digest.decode("utf-8") | |
| return digest_str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| from nacl.signing import SigningKey, VerifyKey | |
| def generate_key_pairs(): | |
| signing_key = SigningKey.generate() | |
| private_key = base64.b64encode(signing_key._signing_key).decode() | |
| public_key = base64.b64encode(bytes(signing_key.verify_key)).decode() | |
| return private_key, public_key |