<p>Hashing is a one way function; the purpose of it is to verify the authenticity of data, <em>not</em> to encrypt data.</p>
<p>If you hash a piece of data, it should be impossible to revert the hash back to it's original form; this is a key operating principle of any hash function.</p>
<p>Generally, when a key-hash is used there should be a point in the process where an associated public/private key is supplied, and is used in combination with the key-hash to perform some sort of true/false evaluation.</p>

CC BY-SA 4.0
2022-01-16T13:24:10.613Z
2022-01-16T13:24:10.613Z
zhekson
<p>I generate my Key Hash Using the Following Function</p>
<pre><code>const getAddressKeyHash = (address) =&gt; {
  return toHex(
    Cardano.Instance.BaseAddress.from_address(
      Cardano.Instance.Address.from_bech32(address)
    )
      .payment_cred()
      .to_keyhash()
      .to_bytes()
  );
};
</code></pre>
<p>Now i need to revert this back to Bech32. Can someone help?</p>

<cardano-serialization-lib>
How can I convert Key Hash to bech32 in Cardano serialization lib?
# How can I convert Key Hash to bech32 in Cardano serialization lib?

(Asked by: username_0 on 2022-01-16)

I generate my Key Hash Using the Following Function
const getAddressKeyHash = (address) => {
  return toHex(
    Cardano.Instance.BaseAddress.from_address(
      Cardano.Instance.Address.from_bech32(address)
    )
      .payment_cred()
      .to_keyhash()
      .to_bytes()
  );
};

Now i need to revert this back to Bech32. Can someone help?

**Tags:** cardano-serialization-lib

---

## 1 answers

### Answer by username_1 on 2022-01-16. Score: 1

Hashing is a one way function; the purpose of it is to verify the authenticity of data, *not* to encrypt data.

If you hash a piece of data, it should be impossible to revert the hash back to it's original form; this is a key operating principle of any hash function.

Generally, when a key-hash is used there should be a point in the process where an associated public/private key is supplied, and is used in combination with the key-hash to perform some sort of true/false evaluation.


---

