6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

※2012/12/5現在の仕様です。将来変更される可能性があります。

chromeでしか動作確認していないのですが、crypto.getRandomValuesを使うと手軽に乱数を生成できます。本番環境では使えませんが、コンソールを開いていて、急に乱数が欲しいってときに便利です。

使い方

// 整数型の型付き配列を用意
var arr = new Uint8Array(10);
// 引数にその型付き配列を入れると全ての要素に乱数が上書きされる
crypto.getRandomValues(arr);

制限

  • 引数に与えられるのは整数型の型付き配列のみ
  • その型付き配列のbyteLength(要素数ではない)は65536以下でないといけない

参考

Web Cryptography API

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?