<html><head><title>Hashing</title><linkrel="stylesheet"type="text/css"href="/static/style.css"></head><body><divclass="sidebar"><divclass="header"><divclass="logo"><ahref="/"><divclass="image"></div><divclass="name">ethers</div><divclass="version">v5.0-beta</div></a></div></div><divclass="toc"><div><divclass="link title"><ahref="/">Documentation</a></div><divclass="base show link depth-1"><ahref="/getting-started/">Getting Started</a></div><divclass="hide link depth-2"><ahref="/getting-started/#installing">Installing</a></div><divclass="hide link depth-2"><ahref="/getting-started/#importing">Importing</a></div><divclass="base show link depth-1"><ahref="/concepts/">Concepts</a></div><divclass="hide link depth-2"><ahref="/concepts/events/">Events</a></div><divclass="hide link depth-3"><ahref="/concepts/events/#solidity-topics">Solidity Topics</a></div><divclass="hide link depth-2"><ahref="/concepts/gas/">Gas</a></div><divclass="hide link depth-3"><ahref="/concepts/gas/#gas-price">Gas Price</a></div><divclass="hide link depth-3"><ahref="/concepts/gas/#gas-limit">Gas Limit</a></div><divclass="base ancestor show link depth-1"><ahref="/api/">Application Programming Interface</a></div><divclass="show link depth-2"><ahref="/api/contract/">Contracts</a></div><divclass="hide link depth-3"><ahref="/api/contract/#buckets">Buckets</a></div><divclass="show link depth-2"><ahref="/api/signer/">Signers</a></div><divclass="hide link depth-3"><ahref="/api/signer/#signer">Signer</a></div><divclass="hide link depth-3"><ahref="/api/signer/#wallet">Wallet</a></div><divclass="hide link depth-3"><ahref="/api/signer/#voidsigner">VoidSigner</a></div><divclass="hide link depth-3"><ahref="/api/signer/#externallyownedaccount">ExternallyOwnedAccount</a></div><divclass="show link depth-2"><ahref="/api/providers/">Providers</a></div><divclass="hide link depth-3"><ahref="/api/providers/provider/">Provider</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#accounts-methods">Accounts Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#blocks-methods">Blocks Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#ethereum-naming-service-(ens)-methods">Ethereum Naming Service (ENS) Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#logs-methods">Logs Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#network-status-methods">Network Status Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#transactions-methods">Transactions Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#event-emitter-methods">Event Emitter Methods</a></div><divclass="hide link depth-4"><ahref="/api/providers/provider/#inspection-methods">Inspection Methods</a></div><divclass="hide link depth-3"><ahref="/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="hide link depth-4"><ahref="/api/providers/jsonrpc-provider/#jsonrpcsigner">JsonRpcSigner</a></div><divclass="hide link depth-4"><ahref="/api/providers/jsonrpc-provider/#jsonrpcuncheckedsigner">JsonRpcUncheckedSigner</a></div><divclass="hide link depth-3"><ahref="/api/providers/api-providers/">API Providers</a></div><divclass="hide link depth-4"><ahref="/api/providers/api-providers/#etherscanprovider">EtherscanProvider</a></div><divclass="hide link depth-4"><ahref="/api/providers/api-providers/#infuraprovider">InfuraProvider</a></div><divclass="hide link depth-4"><ahref="/api/providers/api-providers/#alchemyprovider">AlchemyProvider</a></div><divclass="hide link depth-4"><ahref="/api/providers/api-providers/#cloudfrontprovider">CloudfrontProvider</a></div><divclass="hide link depth-3"><ahref="/api/providers/other/">Other Providers</a></div><divclass="hide link depth-4"><ahref="/api/providers/other/#fallbackprovider">FallbackProvider</a></div><divclass="hide link depth-4"><ahref="/api/providers/other/#ipcprovider">IpcProvider</a></div><divclass="hid
<p>The <ahref="https://en.wikipedia.org/wiki/Cryptographic_hash_function">Cryptographic Hash Functions</a> are a specific family of hash functions.</p>
<aname="utils-ripemd160"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">ripemd160</span> ( <spanclass="param">aBytesLike</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 20 > ></span><divclass="anchors"><aclass="self"href="#utils-ripemd160"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/sha2/src.ts/index.ts#L14">source</a></div></div><divclass="body"><p>Returns the <ahref="https://en.m.wikipedia.org/wiki/RIPEMD">RIPEMD-160</a> digest of <i>aBytesLike</i>.</p></div></div>
<aname="utils-sha256"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">sha256</span> ( <spanclass="param">aBytesLike</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 32 > ></span><divclass="anchors"><aclass="self"href="#utils-sha256"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/sha2/src.ts/index.ts#L18">source</a></div></div><divclass="body"><p>Returns the <ahref="https://en.wikipedia.org/wiki/SHA-2">SHA2-256</a> digest of <i>aBytesLike</i>.</p></div></div>
<aname="utils-sha512"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">sha512</span> ( <spanclass="param">aBytesLike</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 64 > ></span><divclass="anchors"><aclass="self"href="#utils-sha512"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/sha2/src.ts/index.ts#L22">source</a></div></div><divclass="body"><p>Returns the <ahref="https://en.wikipedia.org/wiki/SHA-2">SHA2-512</a> digest of <i>aBytesLike</i>.</p></div></div>
<aname="utils-computehmac"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">computeHmac</span> ( <spanclass="param">algorithm</span> , <spanclass="param">key</span> , <spanclass="param">data</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><divclass="anchors"><aclass="self"href="#utils-computehmac"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/sha2/src.ts/index.ts#L27">source</a></div></div><divclass="body"><p>Returns the <ahref="https://en.wikipedia.org/wiki/HMAC">HMAC</a> of <i>data</i> with <i>key</i> using the <ahref="/api/utils/hashing/#supported-algorithm">Algorithm</a><i>algorithm</i>.</p></div></div>
<aname="utils-hashmessage"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">hashMessage</span> ( <spanclass="param">message</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 32 > ></span><divclass="anchors"><aclass="self"href="#utils-hashmessage"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/hash/src.ts/index.ts#L53">source</a></div></div><divclass="body"><p>Computes the Ethereum message digest of <i>message</i>. Ethereum messages are converted to UTF-8 bytes and prefixed with <codeclass="inline">\x19Ethereum Signed Message:</code> and the length of <i>message</i>.</p></div></div>
<aname="utils-id"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">id</span> ( <spanclass="param">text</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 32 > ></span><divclass="anchors"><aclass="self"href="#utils-id"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/hash/src.ts/index.ts#L47">source</a></div></div><divclass="body"><p>The Ethereum Identity function computs the keccak256 hash of the <i>text</i> bytes.</p></div></div>
<aname="utils-namehash"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">namehash</span> ( <spanclass="param">name</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 32 > ></span><divclass="anchors"><aclass="self"href="#utils-namehash"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/hash/src.ts/index.ts#L29">source</a></div></div><divclass="body"><p>Returns the <ahref="https://docs.ens.domains/contract-api-reference/name-processing#hashing-names">ENS Namehash</a> of <i>name</i>.</p></div></div>
<p>When using the Solidity <codeclass="inline">abi.packEncoded(...)</code> function, a non-standard <i>tightly packed</i> version of encoding is used. These functions implement the tightly packing algorithm.</p>
<aname="utils-soliditypack"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">solidityPack</span> ( <spanclass="param">arrayOfTypes</span> , <spanclass="param">arrayOfValues</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><divclass="anchors"><aclass="self"href="#utils-soliditypack"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/solidity/src.ts/index.ts#L73">source</a></div></div><divclass="body"><p>Returns the non-standard encoded <i>arrayOfValues</i> packed according to their respecive type in <i>arrayOfTypes</i>.</p></div></div>
<aname="utils-soliditykeccak256"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">solidityKeccak256</span> ( <spanclass="param">arrayOfTypes</span> , <spanclass="param">arrayOfValues</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 32 > ></span><divclass="anchors"><aclass="self"href="#utils-soliditykeccak256"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/solidity/src.ts/index.ts#L82">source</a></div></div><divclass="body"><p>Returns the KECCAK256 of the non-standard encoded <i>arrayOfValues</i> packed according to their respective type in <i>arrayOfTypes</i>.</p></div></div>
<aname="utils-soliditysha256"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span> . <spanclass="path">utils</span> . <spanclass="method">soliditySha256</span> ( <spanclass="param">arrayOfTypes</span> , <spanclass="param">arrayOfValues</span> ) <spanclass="arrow">⇒</span><spanclass="returns">string< <ahref="/api/utils/bytes/#datahexstring">DataHexstring</a>< 32 > ></span><divclass="anchors"><aclass="self"href="#utils-soliditysha256"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/solidity/src.ts/index.ts#L86">source</a></div></div><divclass="body"><p>Returns the SHA2-256 of the non-standard encoded <i>arrayOfValues</i> packed according to their respective type in <i>arrayOfTypes</i>.</p></div></div><divclass="footer"><divclass="nav previous"><ahref="/api/utils/fixednumber/"><spanclass="arrow">←</span>FixedNumber</a></div><divclass="nav next"><ahref="/api/utils/hdnode/">HD Wallet<spanclass="arrow">→</span></a></div></div><divclass="copyright">The content of this site is licensed under the <ahref="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons Attribution 4.0 International License</a>.</div></div><scriptsrc="/script.js"type="text/javascript"></script></body></html><!-- ContentHash:c73c28c2355efb3b2cd6b4829cd3c7a12978761ac236c8324e283a1b5965e2ae -->