LoginSignup
2
2

More than 5 years have passed since last update.

素のwindowsで簡単にbase32のランダムな8文字を作る方法

Posted at

こんな文字列
wq20pudk.ei5

win + x, c でコマンドプロンプトを起動する

> [system.io.path]::getrandomfilename()

cmd.exeの人は、

> powershell -c "[system.io.path]::getrandomfilename()"

case-insensitiveなので全部小文字でもOK
import-moduleなしで呼べる

.NETの基本クラスライブラリ(BCL)にあるSystem.IO.Path.GetRandomFileName
https://docs.microsoft.com/ja-jp/dotnet/api/system.io.path.getrandomfilename?view=netstandard-2.0#remarks

base32

普通のbase32は
wikipedia base32
RFC4648 The Base16, Base32, and Base64 Data Encodings
a-z, 2-7, =

GetRandomFilenNameの結果のbase32は、小文字a-zと数字0-5

https://source.dot.net/#System.Private.CoreLib/shared/System/IO/Path.cs,233

s_base32Char = {
                 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
                 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
                 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
                 'y', 'z', '0', '1', '2', '3', '4', '5'};
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2