3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

macOSのコマンドラインでUUIDv4文字列を生成するいくつかの方法

Last updated at Posted at 2025-05-12

1. uuidgenコマンドを使用する

大文字出力

uuidgen

小文字出力

uuidgen | tr '[:upper:]' '[:lower:]'

2. Pythonのuuidモジュールを使用する

大文字出力

python3 -c "import uuid; print(str(uuid.uuid4()).upper())"

小文字出力

python3 -c "import uuid; print(uuid.uuid4())"

3. Node.jsのcryptoモジュールを使用する

大文字出力

node -p "crypto.randomUUID().toUpperCase()"

小文字出力

node -p "crypto.randomUUID()"

thx @ssssota

4. RubyのSecureRandomクラスを使用する

大文字出力

ruby -rsecurerandom -e 'puts SecureRandom.uuid.upcase'

小文字出力

ruby -rsecurerandom -e 'puts SecureRandom.uuid.downcase'

5. SwiftのFoundationフレームワークを使用する

大文字出力

swift -e 'import Foundation; print(UUID().uuidString)'

小文字出力

swift -e 'import Foundation; print(UUID().uuidString.lowercased())'

補足

  • 他にもよい方法があれば追記していきます。
3
1
3

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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?