note 117893 added to function.com-create-guid

From: Date: Thu, 27 Aug 2015 12:37:49 +0000
Subject: note 117893 added to function.com-create-guid
Groups: php.notes 
Request: Send a blank email to php-notes+get-203489@lists.php.net to get a copy of this message
Use more cryptographically strong algorithm to generate pseudo-random bytes and format it as GUID v4 string function guidv4() { if (function_exists('com_create_guid') === true) return trim(com_create_guid(), '{}'); $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } ---- Server IP: 72.52.91.14 Probable Submitter: 37.194.233.217 ---- Manual Page -- http://php.net/manual/en/function.com-create-guid.php Edit -- https://master.php.net/note/edit/117893 Del: integrated -- https://master.php.net/note/delete/117893/integrated Del: useless -- https://master.php.net/note/delete/117893/useless Del: bad code -- https://master.php.net/note/delete/117893/bad+code Del: spam -- https://master.php.net/note/delete/117893/spam Del: non-english -- https://master.php.net/note/delete/117893/non-english Del: in docs -- https://master.php.net/note/delete/117893/in+docs Del: other reasons-- https://master.php.net/note/delete/117893 Reject -- https://master.php.net/note/reject/117893 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203489) next »