FLUTTER ECOSYSTEM

olexale/hashids

하나 또는 여러 숫자에서 YouTube 스타일의 해시를 생성하는 작은 Dart 클래스입니다. https://hashids.org 참조

hashids 프로젝트 이미지
Stars
27
Forks
5
최근 푸시(UTC)
2021. 3. 6.
프로젝트 상태
활성
Oleksandr Leushchenko GitHub avatar
GITHUB User

Oleksandr Leushchenko ↗

Engineering Leader scaling high-impact teams | Google Developer Expert (Flutter & Dart)

언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 2 개

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Hashids2

Build Status Coverage Status pub package

A Dart class to generate YouTube-like hashes from one or many numbers.

Ported from javascript hashids.js by Ivan Akimov

What is it?

Hashids (Hash ID's) creates short, unique, decryptable hashes from unsigned (long) integers.

This algorithm tries to satisfy the following requirements:

  1. Hashes must be unique and decryptable.
  2. They should be able to contain more than one integer (so you can use them in complex or clustered systems).
  3. You should be able to specify minimum hash length.
  4. Hashes should not contain basic English curse words (since they are meant to appear in public places - like the URL).

Instead of showing items as 1, 2, or 3, you could show them as U6dc, u87U, and HMou. You don't have to store these hashes in the database, but can encrypt + decrypt on the fly.

All (long) integers need to be greater than or equal to zero.

Usage

Import the package

Follow instructions from Pub.

Encrypting
final hashids = HashIds();
final fromNumber = hashids.encode(42);
final fromList = hashids.encode([1,2,3]);
final fromString = hashids.encode('42');
Decrypting
final hashids = HashIds();
final number = hashids.decode(fromNumber); // [42]
final list = hashids.decode(fromList); // [1,2,3]
final string = hashids.decode(fromString); // [42]

License

MIT License. See the LICENSE file. You can use Hashids in open source projects and commercial products. Don't break the Internet. Kthxbye.