Geting the hash sha-256 of a file for upload perpuses

What did the trick for me was:

  1. Define an hiden input in elm with type file(So you are not able to use it as a user)
  2. I have defined an onchange function also in the elm side that will allo me to know which file was selected if any
  3. Registering a port function that when invoked trigers the click behaviour of the hidden input
  4. Register onchange callback on the javascript side on the same input object defined in the elm side
  5. when the file changes I calculate in the javascript side the hash of the file using the crypto-js/sha256
  6. using a port I send back the value calculater in the javascript side.
2 Likes