Conversation
| // Load the JSEncrypt library from a CDN | ||
| const script = document.createElement('script'); | ||
| script.src = 'https://cdn.jsdelivr.net/npm/jsencrypt/bin/jsencrypt.min.js'; | ||
| document.head.appendChild(script); |
There was a problem hiding this comment.
You shouldnt be fetching a file url like that as:
- this forces people to need internet for this extension to work
- url could go down at any point
You should use a data.uri instead.
Also add /* global [library name here] */ to fix the lint errors
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
the desktop app still needs to work without internet (this is why the extension library there can only update when the app does, because it's stored offline).
for importing, i think using await import() and making the extension function async is a simple option (and probably also add /+esm to the jsdelivr url so that you can access the library from import()'s return value without adding stuff to the global scope), but you should still make the extension url a data url because of the offline part
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| opcode: 'generateKeys', | ||
| blockType: Scratch.BlockType.REPORTER, | ||
| text: 'Generate RSA keys', | ||
| arguments: {} |
| @@ -0,0 +1,89 @@ | |||
| // Name: RSA | |||
| // ID: themadpunter-rsa | |||
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| class RSAExtension { | ||
| getInfo() { | ||
| return { | ||
| id: 'themadpunter_rsa', |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| getInfo() { | ||
| return { | ||
| id: 'themadpunter_rsa', | ||
| name: 'TurboRSA', |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| { | ||
| opcode: 'generateKeys', | ||
| blockType: Scratch.BlockType.REPORTER, | ||
| text: 'Generate RSA keys', |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| { | ||
| opcode: 'decrypt', | ||
| blockType: Scratch.BlockType.REPORTER, | ||
| text: 'Decrypt [TEXT] with private key [KEY]', |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| } | ||
|
|
||
| // Wait for the script to load before registering the extension | ||
| script.onload = () => { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| } | ||
|
|
||
| generateKeys() { | ||
| const crypt = new JSEncrypt({ default_key_size: 1024 }); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
|
||
| encrypt(args) { | ||
| const crypt = new JSEncrypt(); | ||
| crypt.setPublicKey(args.KEY); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| const crypt = new JSEncrypt(); | ||
| crypt.setPublicKey(args.KEY); | ||
| const encrypted = crypt.encrypt(args.TEXT); | ||
| return encrypted ? encrypted : 'Encryption failed'; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| const crypt = new JSEncrypt(); | ||
| crypt.setPrivateKey(args.KEY); | ||
| const decrypted = crypt.decrypt(args.TEXT); | ||
| return decrypted ? decrypted : 'Decryption failed'; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
An extension to use RSA in TurboWarp.