Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💰 USD 200 BOUNTY: Create example showing in-browser file encryption with private key #72

Closed
3 tasks done
fulldecent opened this issue Nov 24, 2020 · 9 comments
Closed
3 tasks done

Comments

@fulldecent
Copy link

fulldecent commented Nov 24, 2020

I am committing a USD 200 bounty for help that solves this issue.

Work plan

Details

  • Offer is good for 14 days (ends 2020-12-08 at Noon New York)
  • I will pay you using PayPal
  • Offer not valid for people that are legally disallowed to receive payments from USA
  • Anybody else that would like to commit money can increase this number
@xpepermint
Copy link

@xpepermint
Copy link

The correct title should be "Create example showing in-browser file encryption with public key and decryption with private key".

@ChaituVR
Copy link

@xpepermint @fulldecent so the problem here is with

return Buffer.isBuffer(x) && x.length === 32;

as mentioned in #48 (comment)

If you are not using browserify we cant have a Buffer, so the quick fix for you here is to use https://github.com/feross/buffer
instead of Uint8Array

and for CDN we can use unpkg's eccrypto-js which supports file integrity
https://unpkg.com/[email protected]/dist/umd/index.min.js

and here is the codepen for working version
https://codepen.io/ChaituVR/pen/GRjKEMZ

below is HTML that is working

<head>
<title>LET's ENCRYPT</title>
<script src="https://bundle.run/[email protected]"></script>
<script>
    window.Buffer = buffer.Buffer
</script>
<script src="https://unpkg.com/[email protected]/dist/umd/index.min.js"></script>
<script>
    function hexToString(hexString) {
        return new Buffer.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
    }
    (async function(){
      let eccryptoJS = window.eccryptoJS;
      let privateKey = hexToString("8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f");
      let publicKey = eccryptoJS.getPublic(privateKey);
      keyPair = { publicKey, privateKey};
    
      const str = 'test message to encrypt';
      const msg = eccryptoJS.utf8ToBuffer(str);
    
      const encrypted = await eccryptoJS.encrypt(keyPair.publicKey, msg);
      console.log('encrypted:', encrypted);
      const decrypted = await eccryptoJS.decrypt(keyPair.privateKey, encrypted);
      console.log('decrypted:', decrypted);
      let decryptedstring = new TextDecoder("utf-8").decode(decrypted);
      console.log(decryptedstring)
    })()</script>
</head>
<body>
  OPEN CONSOLE
</body>

PS: https://bundle.run/[email protected] this CDN is recommended in https://github.com/feross/buffer

@fulldecent
Copy link
Author

Thank you for the fast reply! @xpepermint please confirm works.

@xpepermint
Copy link

Confirmed!

@fulldecent
Copy link
Author

@ChaituVR thank you for all your help. Please let me know your PayPal email address, or you can send it to me at [email protected].

@fulldecent
Copy link
Author

Thank you for your help. Bounty paid by PayPal. Closing issue.

@fulldecent
Copy link
Author

@ChaituVR please confirm here receipt of payment.

@ChaituVR
Copy link

Received it 👍 thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants