# shorthash2

> Get a unique short hash of a string. Mainly based on shorthash.

Latest version **1.0.5** (published 2024-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install shorthash2
pnpm add shorthash2
yarn add shorthash2
bun add shorthash2
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-09-04 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Jecsham |
| Maintainers | jecsham |
| Keywords | hash, shorthash, shorthash2 |

## Links

- npm: https://www.npmjs.com/package/shorthash2
- Repository: https://github.com/jecsham/shorthash2
- Homepage: https://github.com/jecsham/shorthash2#readme
- Issues: https://github.com/jecsham/shorthash2/issues
- npm.io page: https://npm.io/package/shorthash2

## 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.5 (latest) — 2024-09-04
- 1.0.4 — 2024-07-27
- 1.0.3 — 2020-09-28
- 1.0.2 — 2020-09-28
- 1.0.1 — 2020-09-28
- 1.0.0 — 2020-09-28

## README

# shorthash2
[![NPM](https://nodei.co/npm/shorthash2.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/shorthash2/)

![Build Status](https://github.com/jecsham/shorthash2/actions/workflows/test.yml/badge.svg) [![Codecov branch](https://img.shields.io/codecov/c/github/jecsham/shorthash2/master.svg)](https://codecov.io/gh/jecsham/shorthash2) [![GitHub package.json version](https://img.shields.io/github/package-json/v/jecsham/shorthash2.svg)](https://github.com/jecsham/shorthash2/releases)

> Mainly based on [shorthash](https://github.com/bibig/node-shorthash) (apparently abandoned), by Bibig, **shorthash2** offers a small optimization in memory usage, small features, **typescript** declarations and is available for **browser** and **nodejs**.

+ A mini js lib to generate short, alpha-number, undecryptable and unique hash id from a long string (utf8 format).
+ Use shorthash2 when you want to encrypt a string like a movie name or a people name to a short, unique and url friendly id.
+ so with shorthash2, you can build an id-string map, instead of quering the id from db each time, you just calculate the id out on the fly.
+ it's quite convenient in many conditions if you want to build a site like [书本画](http://shubenhua.com), a book search engine in China.

## Install
As NPM package:

`$ npm i shorthash2`

Or yarn...

`$ yarn add shorthash2`

## Usage


```javascript
import shortHash from "shorthash2";

shortHash('foobar@example.com');
// => Z1bL2tE

shortHash('my name is really big big and big...');
// => Z1TirWS

shortHash('万里长城永不倒。。。');
// => 2r6EFF

shortHash('和平');
// => 33NM

```

### Development
1. Clone repo
2. Install dev dependencies: `$ npm i`
3. Run tests: `$ npm test`

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