# @xrplf/isomorphic

> A collection of isomorphic and tree-shakeable crypto hashes and utils for xrpl.js

Latest version **1.0.2** (published 2026-06-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install @xrplf/isomorphic
pnpm add @xrplf/isomorphic
yarn add @xrplf/isomorphic
bun add @xrplf/isomorphic
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2026-06-04 |
| First published | 2023-10-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18.0.0 |
| Dependencies | 3 |
| Unpacked size | 54.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1327 |
| Maintainers | bmollin, transia, shichengripple001, vjkhannaripple, ripplex-automation |
| Keywords | crypto, isomorphic, xrpl |

## Links

- npm: https://www.npmjs.com/package/@xrplf/isomorphic
- Repository: https://github.com/XRPLF/xrpl.js
- Homepage: https://github.com/XRPLF/xrpl.js#readme
- Issues: https://github.com/XRPLF/xrpl.js/issues
- npm.io page: https://npm.io/package/@xrplf/isomorphic

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) ^8.20.0
- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ^2.0.1
- [eventemitter3](https://npm.io/package/eventemitter3.md) 5.0.1

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2026-06-04
- 1.0.0-beta.1 (beta) — 2023-11-30
- 1.0.1 — 2024-06-03
- 1.0.0 — 2024-02-01
- 1.0.0-beta.0 — 2023-10-20

## README

# @xrplf/isomorphic

A collection of isomorphic implementations of crypto and utility functions.

Browser implementations of cryptographic functions use `@noble/hashes` and `crypto` for node .

### Hashes

All hash functions operate similarly to `@noble/hashes` and have the following properties:

- They can be called directly by providing a Uint8Array or string which will be converted into a UInt8Array via UTF-8 encoding (not hex).
- They all return a UInt8Array.

```
function hash(message: Uint8Array | string): Uint8Array;
hash(new Uint8Array([1, 3]));
hash('string') == hash(new TextEncoder().encode('string'));
```

All hash functions can be constructed via `hash.create()` method:

- The result is `Hash` subclass instance, which has `update()` and `digest()` methods.
- `digest()` finalizes the hash and makes it no longer usable

```typescript
hash
  .create()
  .update(new Uint8Array([1, 3]))
  .digest();
```

### `@xrplf/isomorphic/ripemd160`
```typescript
import { ripemd160 } from '@xrplf/isomorphic/ripemd160';
const hashA = ripemd160('abc');
const hashB = ripemd160
  .create()
  .update(Uint8Array.from([1, 2, 3]))
  .digest();
```

### `@xrplf/isomorphic/sha256`

```typescript
import { sha256 } from '@xrplf/isomorphic/sha256';
const hashA = sha256('abc');
const hashB = sha256
  .create()
  .update(Uint8Array.from([1, 2, 3]))
  .digest();
```

### `@xrplf/isomorphic/sha512`

```typescript
import { sha512 } from '@xrplf/isomorphic/sha512';
const hashA = sha512('abc');
const hashB = sha512
  .create()
  .update(Uint8Array.from([1, 2, 3]))
  .digest();
```

## Utilities

### `@xrplf/isomorphic/utils`

#### randomBytes

Create an UInt8Array of the supplied size

```typescript
import { randomBytes } from @xrplf/isomorphic/utils

console.log(randomBytes(12)) // Uint8Array(12) [95, 236, 188,  55, 208, 128, 161, 249, 171, 57, 141, 7]
```

#### bytesToHex

Convert an UInt8Array to hex.

```typescript
import { bytesToHex } from @xrplf/isomorphic/utils

console.log(bytesToHex([222, 173, 190, 239])) // "DEADBEEF"
```

#### hexToBytes

Convert hex to an UInt8Array.

```typescript
import { hexToBytes } from @xrplf/isomorphic/utils

console.log(hexToBytes('DEADBEEF')) // [222, 173, 190, 239]
```

#### hexToString

Converts hex to its string equivalent. Useful to read the Domain field and some Memos.

```typescript
import { hexToString } from @xrplf/isomorphic/utils

console.log(hexToString('6465616462656566D68D')) // "deadbeef֍"
```

#### stringToHex

Converts a utf-8 to its hex equivalent. Useful for Memos.

```typescript
import { stringToHex } from @xrplf/isomorphic/utils

console.log(stringToHex('deadbeef֍')) // "6465616462656566D68D"
```

### `@xrplf/isomorphic/ws`

```typescript
import WebSocket from '@xrplf/isomorphic/ws'

const socket = new WebSocket('wss://localhost:8080')
```

---
_Source: https://npm.io/package/@xrplf/isomorphic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
