Skip to content

hash Produces Incorrect SHA256 for some (perhaps Large?) Files #99

Open

Description

@a-ghorbani

Description

RNFS.hash does not produce the correct SHA256 hash for some (perhaps large) files.
The hash calculated by RNFS.hash differs from the expected value computed using standard tools like shasum and matches the hash reported on the file's source page.

note: My testing has been on GGUF files from Hugging Face, which are typically a few GBs in size. I have not faced this issue with smaller files, from my observation it seems they occurs with files around 1 GB or larger.

Steps to Reproduce:

  1. Download the file: Model-7.6B-Q4_K_S.gguf
  2. Place the file in the app's accessible directory (e.g., RNFS.DocumentDirectoryPath)
  3. use await RNFS.hash(filePath, 'sha256'); to get the hash
  4. compare the value either with the reported one on HF page, or shasum -a 256 /PATH/TO/SIMULATOR/DIR/Model-7.6B-Q4_K_S.gguf

Expected Behavior:

The hash returned by RNFS.hash should match the expected SHA256 value: 6d28c300dab7c224f9b34afcca0e0413c985846482f62e49b2cef109f82af926

Actual Behavior:

RNFS.hash returns: 1ba0bd6473b9f7b5a2a355256854ee4345e7abf229361363d745387b4c151958

Additional Information:

RNFS version: 2.30.1
React Native version: 0.76.3
Platform: iOS (Simulator)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority issue.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions