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

Android - Hash method still suffers from fix done for other on PR #395 #418

Closed
castro13 opened this issue Jan 16, 2018 · 3 comments
Closed

Comments

@castro13
Copy link

While trying to use the 'hash' method on Android, I was getting the same error that the PR #395 fixed.
I did a local fix to have ti working.

Is there any possibility of fixing the hash method?
Below is my fix.

  if (!algorithms.containsKey(algorithm)) throw new Exception("Invalid hash algorithm");

  // File file = new File(filepath);

  // if (file.isDirectory()) {
  //   rejectFileIsDirectory(promise);
  //   return;
  // }

  // if (!file.exists()) {
  //   rejectFileNotFound(promise, filepath);
  //   return;
  // }

  MessageDigest md = MessageDigest.getInstance(algorithms.get(algorithm));

  // FileInputStream inputStream = new FileInputStream(filepath);
  // byte[] buffer = new byte[(int) file.length()];

  InputStream inputStream = getInputStream(filepath);
  byte[] buffer = new byte[1024];
@andrewkvavlewhite
Copy link

I use this package only for the file hash function. I made a fork temporarily with the above fix if anyone else only cares about the hash function. https://github.com/andrewkvavlewhite/react-native-fs

@itinance
Copy link
Owner

itinance commented Feb 17, 2018

I wonder why nobody send a PR with this fix?
I have changed now the buffer creation to a fix buffer size of 10 KB in the hash-function.

Please find the fix in latest release of v2.9.10

@tong233
Copy link

tong233 commented Jul 4, 2018

Thanks. it is working

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

4 participants