Skip to content

Instantly share code, notes, and snippets.

@stevenwoodson
Created October 30, 2014 16:15
Show Gist options
  • Save stevenwoodson/ce23ca45caa8f38fbaf0 to your computer and use it in GitHub Desktop.
Save stevenwoodson/ce23ca45caa8f38fbaf0 to your computer and use it in GitHub Desktop.
Random Unique String
<?php
// Generates a string of random bytes of the provided number (7 in the example below) and then converts that binary to hexadecimal
// The hexadecimal conversion doubles the string size so the final result in the example below will be 14 characters long.
echo bin2hex(openssl_random_pseudo_bytes(7));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment