Created
March 30, 2026 22:37
-
-
Save kuboon/cadce44a0f1f91f8f00aac6addd3b756 to your computer and use it in GitHub Desktop.
cryptid.ts
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 CryptID from "https://esm.sh/@cryptid/cryptid-js/lib/node/js/index.js"; | |
| (async function main() { | |
| const instance = await CryptID.getInstance(); | |
| const setupResult = instance.setup(CryptID.SecurityLevel.LOWEST); | |
| if (!setupResult.success) { | |
| console.log('Failed to setup :('); | |
| return; | |
| } | |
| const message = 'Ironic.'; | |
| // Name is somewhat unique among Sith Lords :) | |
| const identity = { | |
| name: 'Darth Plagueis' | |
| }; | |
| const encryptResult = instance.encrypt(setupResult.publicParameters, identity, message); | |
| if (!encryptResult.success) { | |
| console.log('Failed to encrypt :('); | |
| return; | |
| } | |
| const extractResult = instance.extract(setupResult.publicParameters, setupResult.masterSecret, identity); | |
| if (!extractResult.success) { | |
| console.log('Failed to extract :('); | |
| return; | |
| } | |
| const decryptResult = instance.decrypt(setupResult.publicParameters, extractResult.privateKey, encryptResult.ciphertext); | |
| if (!decryptResult.success) { | |
| console.log('Failed to decrypt :('); | |
| return; | |
| } | |
| console.log(decryptResult.plaintext); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment