Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 2
    rand doesn't use /dev/urandom because that is only available in posix like environments and is not portable. Commented Mar 25, 2014 at 9:22
  • 3
    @MacroMan But openssl_random_pseudo_bytes() is portable. Commented Jul 29, 2014 at 5:29
  • If you want to strip out the extra base64 characters, try this: gist.github.com/zyphlar/7217f566fc83a9633959 Commented Dec 20, 2014 at 22:38
  • 4
    This isn't wrong, but I would advise caution in how you discard the unwanted characters. See this pull request on the PHP league's OAuth2 Server, for example. Commented Jul 6, 2015 at 6:11
  • This is one of the best answers. Pity it doesn't have more support. I would recommend editing your answer for better handling of unwanted characters though. Commented Aug 4, 2016 at 18:32