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

[9.x] Add support for multiple hash algorithms #43407

Merged

Conversation

medeirosinacio
Copy link
Contributor

@medeirosinacio medeirosinacio commented Jul 25, 2022

We often need the sha256 of the file, it would be interesting for Filesystem to get it.

I was always confused by the original implementation, as "hash" refers me to all sorts of algorithms. That way we don't break what already exists (md5 default) and enable hashing like sha256 or sha512.

https://www.php.net/manual/en/function.hash-algos.php

File::hash($path)
// 196b0f14eba66e10fba74dbf9e99c22f => default md5

File::hash($path, 'sha256')
// 19c451aedfb24c338a9a2a5c31d553ed77e7cdefc655035f390176ac24066051

* @return string
*/
public function hash($path)
public function hash($path, $algorithm = 'md5')
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change to the method signature unfortunately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had done PR for version v10, but they asked to do it for v9.
Let me know if I need to change anything.

#43378 (comment)

@taylorotwell taylorotwell merged commit 990f43e into laravel:9.x Jul 25, 2022
@taylorotwell
Copy link
Member

I think this is probably OK - unlikely it was being overwritten.

Ken-vdE pushed a commit to Ken-vdE/framework that referenced this pull request Aug 9, 2022
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

Successfully merging this pull request may close these issues.

3 participants