Skip to content

higmsys/MyId

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyId - Random ID Generation Library

Overview

MyId is a C# library that generates random IDs using any character set and length you specify.
Unlike UUIDs, which are fixed at 32 characters, MyId allows you to flexibly generate IDs tailored to your use case.

Typical Use Cases

  • Generating user IDs
  • Generating log trace IDs
  • Creating unique SQL parameter names

Features

  • Generate IDs of any length
  • Specify the character set to use
  • Add prefixes or suffixes
  • Supports built‑in character sets (alphanumeric, Base32, Base64, etc.) and custom character sets

Built‑in Character Sets

  • Alphanumeric (A–Z, a–z, 0–9)
  • Uppercase letters + digits (A–Z, 0–9)
  • Lowercase letters + digits (a–z, 0–9)
  • Base32 (A–Z, 2–7)
  • Base64 (A–Z, a–z, 0–9, +, /)

Main Classes

  • MyIdGenerator
    The primary class for generating IDs. You configure options and generate IDs.

  • MyIdOptions
    Specifies generation options such as character set, length, and customization function.

  • MyIdCharset
    Defines a character set. You can use built‑in sets or provide your own.

Usage Examples

  1. Using a built‑in character set

    var options = new MyIdOptions
    {
        Charset = MyIdCharset.AlphabetNumeric,
        Length = 16
    };
    var generator = new MyIdGenerator(options);
    string id = generator.GenerateId();

    Example output: bWN5BVMK3l67p2ft

  2. Using a custom character set

    var options = new MyIdOptions
    {
        Charset = new MyIdCharset("abc123"),
        Length = 8
    };
    var generator = new MyIdGenerator(options);
    string id = generator.GenerateId();

    Example output: 3b231c3c

  3. Adding a prefix

    var options = new MyIdOptions
    {
        Charset = MyIdCharset.AlphabetNumeric,
        Length = 16,
        Customize = args => $"hello-{args.OriginalId}"
    };
    var generator = new MyIdGenerator(options);
    string id = generator.GenerateId();

    Example output: hello-oTgSk9REWjbR41Tb

----------------------------------------------------

MyId - ランダムID生成ライブラリ

概要

MyIdは、C#で任意の文字セット・長さでランダムなIDを生成できるライブラリです。
UUIDのような32桁固定ではなく、用途に応じて柔軟にIDを生成できます。

主な用途

  • ユーザーIDの生成
  • ログトレースIDの生成
  • SQLパラメータ名の識別子生成

主な機能

  • 任意の長さでIDを生成
  • 利用する文字セットを指定可能
  • プレフィックス/サフィックスの付与
  • 組み込み文字セット(英数字、Base32, Base64等)やカスタム文字セットに対応

組み込み文字セット例

  • 英数字(A-Z, a-z, 0-9)
  • 大文字英字+数字(A-Z, 0-9)
  • 小文字英字+数字(a-z, 0-9)
  • Base32(A-Z, 2-7)
  • Base64(A-Z, a-z, 0-9, +, /)

主要クラス

  • MyIdGenerator
    ID生成のためのメインクラス。オプションを指定してIDを生成します。

  • MyIdOptions
    生成時のオプション(文字セット、長さ、カスタマイズ関数など)を指定します。

  • MyIdCharset
    文字セットを定義するクラス。組み込みセットや任意のセットを利用可能。

使用例

  1. 組み込み文字セット

    var options = new MyIdOptions
    {
        Charset = MyIdCharset.AlphabetNumeric,
        Length = 16
    };
    var generator = new MyIdGenerator(options);
    string id = generator.GenerateId();

    実行例:bWN5BVMK3l67p2ft

  2. カスタム文字セット

    var options = new MyIdOptions
    {
        Charset = new MyIdCharset("abc123"),
        Length = 8
    };
    var generator = new MyIdGenerator(options);
    string id = generator.GenerateId();

    実行例:3b231c3c

  3. プレフィックス付与

    var options = new MyIdOptions
    {
        Charset = MyIdCharset.AlphabetNumeric,
        Length = 16,
        Customize = args => $"hello-{args.OriginalId}"
    };
    var generator = new MyIdGenerator(options);
    string id = generator.GenerateId();

    実行例:hello-oTgSk9REWjbR41Tb

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages