<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>katsube</author_name>
  <author_url>https://blog.hatena.ne.jp/katsube/</author_url>
  <blog_title>ねこの足跡R</blog_title>
  <blog_url>https://blog.katsubemakito.net/</blog_url>
  <categories>
    <anon>Node.js</anon>
    <anon>JavaScript</anon>
    <anon>Math.random()</anon>
    <anon>crypto</anon>
    <anon>乱数</anon>
  </categories>
  <description>JavaScriptで乱数を利用したい場合はMath.random()を使うことがほとんどだと思いますが、内部のロジック的に暗号などセキュアな用途には向いていないとされています。Node.jsでは標準モジュールであるcryptoを利用することでこの問題を解決することができます。 サンプルコード 結論から言うと具体的なコードは以下になります。getSecureRandom()関数を実行する度にランダムな整数を取得できます。 const Crypto = require(&quot;crypto&quot;); function getSecureRandom(){ const buff = Crypto.rando…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.katsubemakito.net%2Fnodejs%2Fsecure-random-value&quot; title=&quot; [Node.js] Math.random()よりセキュアな乱数を生成する - ねこの足跡R&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2019-07-14 02:21:17</published>
  <title> [Node.js] Math.random()よりセキュアな乱数を生成する</title>
  <type>rich</type>
  <url>https://blog.katsubemakito.net/nodejs/secure-random-value</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
