搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.0

hashids2

Hashids 是一個小規模的程式庫,可從數字產生類似 YouTube 的 ID。當您不希望向使用者暴露資料庫 ID 時,請使用 Hashids。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
9600
喜歡數
29
Pub 分數
140

安裝套件

flutter pub add hashids2

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Hashids2 是一個輕量級的 Dart 套件,可將數字轉換為短小、唯一且 URL 安全的 ID,類似於 YouTube 的 ID 格式。它旨在混淆資料庫 ID,防止使用者猜測或操縱順序識別碼。適用於需要透過隱蔽性增強安全性的公開應用。該套件支援多種平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,使其在跨平台應用中具有高度彈性。它使用可自訂的鹽值和長度設定,以確保唯一性並控制輸出格式。

適用情境

  • 在URL中混淆資料庫ID
  • 產生短的唯一識別碼
  • 防止API端點的ID枚舉
  • 建立使用者友善的可分享連結
  • 防止公共 API 中的順序 ID 暴露

主要特色

  • 從數字生成 URL 安全的字串
  • 可自定的鹽值和最小長度
  • 跨平台相容性
  • 與 Flutter 應用的簡單整合
  • 支援編碼和解碼

適合對象

  • 需要安全ID生成的Web和移動應用
  • 想要隱藏資料庫結構的開發人員
  • 具有面向公眾的標識符的應用程式
  • 需要簡單混淆而無需複雜加密的項目

使用建議

  • 不適合高安全性加密需求
  • 需要仔細管理鹽以確保唯一性
  • 不提供加密或驗證
  • 輸出長度取決於輸入大小和設定
  • 僅限ID混淆,不提供完整資料保護

原始 README

以下為關聯原始碼儲存庫的 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。