teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

訂正

2019/09/12 21:28

投稿

7968
7968

スコア253

title CHANGED
File without changes
body CHANGED
@@ -58,4 +58,6 @@
58
58
 
59
59
  **何バイトから安全と言えるのでしょうか?**
60
60
 
61
+ なぜ、そのバイト数なのかも教えていただけると嬉しいです。
62
+
61
63
  ご存じの方いれば、教えてください。

1

訂正

2019/09/12 21:28

投稿

7968
7968

スコア253

title CHANGED
File without changes
body CHANGED
@@ -32,7 +32,16 @@
32
32
  抜粋しているので、詳細のコードは引用元を参照してください。
33
33
 
34
34
  ```
35
+ public static function random($length = 16)
36
+ {
37
+ $string = '';
38
+ while (($len = strlen($string)) < $length) {
39
+ $size = $length - $len;
40
+ $bytes = random_bytes($size);
35
- substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size)
41
+ $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
42
+ }
43
+ return $string;
44
+ }
36
45
  ```
37
46
 
38
47
  引用:[Qiita - CSRFトークン インタビューズ](https://qiita.com/kinyuka/items/0fcccf2db285b704dcb8#laravel)