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

[Feat] Switching from md5 to sha256. Issue no. 31748 #31910

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-server/src/ReactServerStreamConfigNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export function closeWithError(destination: Destination, error: mixed): void {
}

export function createFastHash(input: string): string | number {
const hash = createHash('md5');
const hash = createHash('sha256');
hash.update(input);
return hash.digest('hex');
}
8 changes: 8 additions & 0 deletions packages/react-server/src/__tests__/ReactServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

let React;
let ReactNoopServer;
let sha256;

describe('ReactServer', () => {
beforeEach(() => {
jest.resetModules();

React = require('react');
ReactNoopServer = require('react-noop-renderer/server');
sha256 = require('../ReactServerStreamConfigNode.js')
});

function div(...children) {
Expand All @@ -32,4 +34,10 @@ describe('ReactServer', () => {
const result = ReactNoopServer.render(<div>hello world</div>);
expect(result.root).toEqual(div('hello world'));
});

it('correctly computes sha256', () =>{
const expectedOutput = 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9';
const hash = sha256.createFastHash('hello world');
expect(hash).toBe(expectedOutput);
});
});