# `BSV.Crypto`
[🔗](https://github.com/Bittoku/bsv_sdk_elixir/blob/main/lib/bsv/crypto.ex#L1)

Cryptographic hash functions using OTP `:crypto`.

# `hash160`

```elixir
@spec hash160(binary()) :: &lt;&lt;_::160&gt;&gt;
```

Hash160: RIPEMD160(SHA256(data)).

# `ripemd160`

```elixir
@spec ripemd160(binary()) :: &lt;&lt;_::160&gt;&gt;
```

RIPEMD-160 hash.

# `secure_compare`

```elixir
@spec secure_compare(binary(), binary()) :: boolean()
```

Constant-time binary comparison.

Prevents timing side-channel attacks when comparing secrets (HMACs, keys, etc.).
Returns `true` if both binaries are equal, `false` otherwise.
Always examines every byte regardless of where the first difference occurs.

# `sha256`

```elixir
@spec sha256(binary()) :: &lt;&lt;_::256&gt;&gt;
```

SHA-256 hash.

# `sha256_hmac`

```elixir
@spec sha256_hmac(binary(), binary()) :: &lt;&lt;_::256&gt;&gt;
```

HMAC-SHA256.

# `sha256d`

```elixir
@spec sha256d(binary()) :: &lt;&lt;_::256&gt;&gt;
```

Double SHA-256 hash.

# `sha512`

```elixir
@spec sha512(binary()) :: &lt;&lt;_::512&gt;&gt;
```

SHA-512 hash.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
