Navigation Menu

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

[DO NOT MERGE]: feat(crypto): play with webcrypto API #1071

Closed
wants to merge 2 commits into from

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Oct 7, 2020

play with web-crypto API, so that we can provide feedback to Node.js project.

@bcoe bcoe requested a review from a team as a code owner October 7, 2020 23:23
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 7, 2020
return crypto.randomBytes(count).toString('base64');
const array = new Uint8Array(count);
webcrypto.getRandomValues(array);
return base64js.fromByteArray(array);
Copy link
Member

Choose a reason for hiding this comment

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

Since we're in Node context, we still can use Buffer.from here, right?

Copy link
Contributor Author

@bcoe bcoe Oct 8, 2020

Choose a reason for hiding this comment

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

In playing I couldn't seem to, seems like this might be a good improvement.

@@ -14,32 +14,100 @@

import * as crypto from 'crypto';
import {Crypto} from '../crypto';
import * as base64js from 'base64-js';
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is cool and all, but the real test would be to delete this file, and rely on the browser context one we've already written :) That is already using SubtleCrypto, so if node is API compatible it should slide right in. This PR could just be a deleted file!

@bcoe bcoe closed this Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants