カテゴリー・パッケージ・リポジトリを検索

パッケージ詳細v2.3.1

random_string

デフォルトで 'dart:math' の Random を使用してランダムな ASCII 文字列を生成する簡単なライブラリ。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
16.5万
いいね数
203
Pub ポイント
160

パッケージをインストール

flutter pub add random_string

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Dart の組み込み Random クラスを使用してランダムな ASCII 文字列を生成する簡単な Flutter/Dart パッケージです。指定された長さのランダム文字列を作成するための使いやすい API を提供しており、一時的なトークン、パスワード、識別子などのシナリオに最適です。このライブラリは軽量でプラットフォーム非依存であり、Android、iOS、Web、macOS、Windows、Linux などすべての主要プラットフォームをサポートしています。コア Dart SDK 以外の外部依存関係は必要ありません。

用途

  • 一時パスワードの生成
  • 一意の識別子を作成する
  • テストデータの作成
  • 認証のためのトークン生成
  • アプリケーションでランダムな入力をシミュレートする

主な機能

  • 最小限のセットアップで簡単なAPI
  • Dart の Random クラスを使用
  • カスタム長さおよび文字セットをサポート
  • クロスプラットフォーム互換性
  • 軽量で依存関係なし

適している対象

  • 迅速なランダム文字列生成が必要な開発者
  • テストとプロトタイピング
  • 認証とセッション管理
  • 一意のIDまたはコードを必要とするアプリ

注意事項

  • デフォルトではASCII文字に制限されています
  • 暗号化セキュリティの保証なし
  • 拡張なしでは、Unicodeまたは特別文字のカスタマイズをサポートしていません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

random_string

Simple library for generating random ascii strings.

Design goals and limitations

While this package provides randomBetween for convenience, as the name implies, the design goal of this package is for random generation of ascii strings, particularly for testing and not for cryptographic purposes.
With that stated, consider an alternative means of random number generation if your needs fall outside these goals and limitations.

Usage

A simple usage example:

import 'package:random_string/random_string.dart';
import 'dart:math' show Random;

main() {
  print(randomBetween(10, 20)); // some integer between 10 and 20 where 0 <= min <= max <= 999999999999999
  print(randomNumeric(4)); // sequence of 4 random numbers i.e. 3259
  print(randomString(10)); // random sequence of 10 characters i.e. e~f93(4l-
  print(randomAlpha(5)); // random sequence of 5 alpha characters i.e. aRztC
  print(randomAlphaNumeric(10)); // random sequence of 10 alpha numeric i.e. aRztC1y32B

  var r = Random.secure();
  print(randomBetween(10, 20, provider: CoreRandomProvider.from(r))); // You can use a provider from Random.
  print(randomBetween(10, 20, provider: _Provider())); // Or you can implement your own.
}

class _Provider with AbstractRandomProvider {
  _Provider();
  double nextDouble() => 0.5;
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト