Last updated: May 29, 2024

<span aria-hidden="true" id="introducing-the-filehash-robot-for-file-integrity"></span>

# Introducing the /file/hash Robot for file integrity

![Joseph Grabski](/assets/images/teammates/joseph2.png?dpl=dpl_3fBRD5jmFtSDABLXGJJyXU1nVXf8)

**Joseph Grabski**

Content Lead · Rochester, United Kingdom · Show bio

[](https://x.com/joe%5Fgrabski)[](https://github.com/Missing-Tech)

It's time again to welcome a new Robot to the Transloadit family. Say hello to the[/file/hash](/docs/robots/file-hash.md) Robot. With its introduction, it's now possible to hash any file that's part of your Assembly execution process, proving particularly useful in verifying the integrity of your file.

There are several algorithms at your fingertips to choose from too, whether you're looking to use the speedy MD5 algorithm, or a more secure option, such as SHA-512.

After the Robot is finished hashing your file, it'll store the file's hash under the`file.meta.hash` property, for you to access in later Steps.

![/file/hash Robot](/_next/static/immutable/media/opengraph-image.0dck3ih-soi8u.png)

<span aria-hidden="true" id="file-hashing-in-action"></span>

## File hashing in action

As an example, let's take a look at what a Template could look like if we wanted to verify a file has changed after it has been resized. We'll first take our uploaded file and hash it. Then, resize the original file and hash it again. Simply compare the hash from the resized image to the original hashed image. If they're different, then we know that our file has been resized.

Here's what that looks like:

```json
{
  "steps": {
    ":original": {
      "robot": "/upload/handle"
    },
    "resize_image": {
      "use": ":original",
      "robot": "/image/resize",
      "height": 500,
      "imagemagick_stack": "{{stacks.imagemagick.recommended_version}}",
      "resize_strategy": "fit"
    },
    "hash_original": {
      "use": ":original",
      "robot": "/file/hash",
      "result": true,
      "algorithm": "sha1"
    },
    "hash_resized": {
      "use": "resize_image",
      "robot": "/file/hash",
      "result": true,
      "algorithm": "sha1"
    }
  }
}

```

Notice how we're using the `sha1` algorithm? You can easily change the `algorithm` parameter to any of these options below to generate hashes with different algorithms for different use-cases.

* `b2`
* `md5`
* `sha1`
* `sha224`
* `sha256`
* `sha384`
* `sha512`

<span aria-hidden="true" id="testing"></span>

## Testing

Now, let's put our Template through its paces. Upload an image and take a look at the hash that is generated for the file, and if it changes throughout our Steps.

**Step: `hash_files`** ![Cat staring into camera](/_next/static/immutable/media/2021-12-initial-script-run-cat.1y-vcgeoa5_4t.jpg) `meta.hash:924eb08378f97f1fe2744b77a79373078af3487c`

**Step: `resize_image`** ![Cat staring into camera](/_next/static/immutable/media/2022-07-hashed-file-resized.29ucjfoy6snw_.jpeg) `meta.hash:c51c917811c2b3a515c303b682c610224aa77621`

As expected, the hashes generated for both of our files are different, meaning our image was resized.

<span aria-hidden="true" id="until-next-time"></span>

## Until next time

That's the end of our whistle-stop tour of the [/file/hash](/docs/robots/file-hash.md) Robot. Sign up below with Transloadit and have a play around yourself with theRobot, as well as our [array](/services.md) of other Robots.

[#file-hash-robot](/blog/tags/file-hash-robot.md)[#media-cataloging-service](/blog/tags/media-cataloging-service.md)[#walkthrough](/blog/tags/walkthrough.md)

### 👩‍💻 Join 20k+ developers

Sign up for our [monthly newsletter](/newsletters.md) to receive direct links to 3 exclusive tech — and 2 product updates. No less, no more.

Your email:

Get access

## File uploading and encoding. Made simple.

Transloadit streamlines file handling for developers, trusted by brands like Coursera and The New York Times. We’re known for a reliable API, top-notch support, and a strong commitment to open source, with projects like [Uppy⁠](https://uppy.io) and [Tus⁠](https://tus.io) setting standards in file processing.

[Sign up](/c/)[Book a Demo](https://survey.typeform.com/to/kRg47Xi5)

No credit card needed · 5 GB included in the free plan

Cancel anytime
