# Creating a basic SHA256 hasher in Circom

**URL:** https://community.zkproof.org/t/creating-a-basic-sha256-hasher-in-circom/701
**Category:** Miscellaneous
**Created:** [July 28, 2022, 11:40pm UTC](https://community.zkproof.org/t/creating-a-basic-sha256-hasher-in-circom/701 "2022-07-28T23:40:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lostatcplusplus](https://avatars.discourse-cdn.com/v4/letter/l/5e9695/32.png) [@lostatcplusplus](https://community.zkproof.org/u/lostatcplusplus)
#### Post date: [July 28, 2022, 11:40pm UTC](https://community.zkproof.org/t/creating-a-basic-sha256-hasher-in-circom/701/1 "2022-07-28T23:40:01Z")

</div>

I want to create a SHA256 hasher in Circom so I can validate that a person knows the pre-image of a SHA256 hash without revealing the pre-image. This is my current code but it doesn’t work:

```auto
include "/node_modules/circomlib/circuits/sha256/sha256.circom"

template SHAHasher(nBits) {
  signal input bits[nBits];
  signal output newHash[256];

  component shaHash = Sha256(nBits);

  for (var i=0; i<nBits; i++) {
    shaHash.in[i] <== bits[i];
  }

  for (var i=0; i<256; i++) {
    newHash[i] <== shaHash.out[i];
  }
}

```

Thank you in advance, any help would be greatly appreciated.
