Skip to content

RSA Extension#1699

Closed
familycomicsstudios wants to merge 3 commits intoTurboWarp:masterfrom
familycomicsstudios:master
Closed

RSA Extension#1699
familycomicsstudios wants to merge 3 commits intoTurboWarp:masterfrom
familycomicsstudios:master

Conversation

@familycomicsstudios
Copy link

@familycomicsstudios familycomicsstudios commented Sep 24, 2024

An extension to use RSA in TurboWarp.

@GarboMuffin GarboMuffin added the pr: new extension Pull requests that add a new extension label Oct 14, 2024
@SharkPool-SP SharkPool-SP self-requested a review October 18, 2024 06:37
Comment on lines +10 to +13
// 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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

@CST1229 CST1229 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

opcode: 'generateKeys',
blockType: Scratch.BlockType.REPORTER,
text: 'Generate RSA keys',
arguments: {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary key

Copy link

@yuri-kiss yuri-kiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm

@@ -0,0 +1,89 @@
// Name: RSA
// ID: themadpunter-rsa

This comment was marked as abuse.

class RSAExtension {
getInfo() {
return {
id: 'themadpunter_rsa',

This comment was marked as abuse.

getInfo() {
return {
id: 'themadpunter_rsa',
name: 'TurboRSA',

This comment was marked as abuse.

{
opcode: 'generateKeys',
blockType: Scratch.BlockType.REPORTER,
text: 'Generate RSA keys',

This comment was marked as abuse.

{
opcode: 'decrypt',
blockType: Scratch.BlockType.REPORTER,
text: 'Decrypt [TEXT] with private key [KEY]',

This comment was marked as abuse.

}

// Wait for the script to load before registering the extension
script.onload = () => {

This comment was marked as abuse.

}

generateKeys() {
const crypt = new JSEncrypt({ default_key_size: 1024 });

This comment was marked as abuse.


encrypt(args) {
const crypt = new JSEncrypt();
crypt.setPublicKey(args.KEY);

This comment was marked as abuse.

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.

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.

@Thebloxers998

This comment was marked as spam.

@yuri-kiss

This comment was marked as spam.

@yuri-kiss

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: new extension Pull requests that add a new extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants