Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72036 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73924 invoked from network); 3 Feb 2014 05:09:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2014 05:09:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.174 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:53656] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/50-03615-3742FE25 for ; Mon, 03 Feb 2014 00:09:08 -0500 Received: by mail-lb0-f174.google.com with SMTP id l4so4908535lbv.5 for ; Sun, 02 Feb 2014 21:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=QjQt75DotMkxPX+RgSF+W3JAXOoWUDGaOZRI0sQsTaQ=; b=hWlNwo2I0n3P/3SXlEyweXAOn0C2rOInzfL7t3ea/ZOf13WADHtaSEeoAQWXUJ/oxr 3Q3T3vPEi0XdyDE8LjitoPRUtAN6HKKmivc5zTrJnPUCYgq4WB55oakWk2AEp23o565/ klQ2G8owc0SPiYUD9n40XAzgFZmEU13cR89cj/XpvhiiEGY1yAQCM5TAWCp39avLlYSW y0iwWyqLM9QwjIOpkW/0fKg/+UVrqeU4tyC79xfYfKClGffDrPpBipaUkER+qPAzkQnQ XzZSoNS8xTpN1u0rYJOvr6ejp30FIscwfhfDiLRrj2gpw0UE3MybrxUuWFAbj0R5DWxE lw/Q== X-Received: by 10.152.219.97 with SMTP id pn1mr22998184lac.9.1391404144783; Sun, 02 Feb 2014 21:09:04 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Sun, 2 Feb 2014 21:08:24 -0800 (PST) In-Reply-To: References: <52EDF552.4010208@divbyzero.net> Date: Mon, 3 Feb 2014 14:08:24 +0900 X-Google-Sender-Auth: eJjWNlDG9nEzkr8Rag62yePQOLo Message-ID: To: Tjerk Meesters Cc: Martin Jansen , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1137f67cc9f52804f179857a Subject: Re: [PHP-DEV] Extending uniqid() or not? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1137f67cc9f52804f179857a Content-Type: text/plain; charset=UTF-8 Hi Tjerk, On Mon, Feb 3, 2014 at 1:59 PM, Tjerk Meesters wrote: > On Mon, Feb 3, 2014 at 9:13 AM, Yasuo Ohgaki wrote: > >> Hi Tjerk, >> >> On Mon, Feb 3, 2014 at 8:55 AM, Tjerk Meesters wrote: >> >>> I think it would be good enough to have only uuid v4: >>> >>> function uuidv4() >>> { >>> $data = openssl_random_pseudo_bytes(16); // or whatever >>> >>> $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010 >>> $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)); >>> } >>> >>> It's really just a representation of random data, whereby 6 bits are >>> used for the actual format. >>> >> >> I agree. >> UUID v4 simply generate random ID and it is good for many purposes. >> >> My concern is portability. OpenSSL(or Mcrypt) is provided as module. >> Users tends not to use module functions whenever possible. To address >> this issue, OpenSSL could be a module compiled by default. >> > > You could simply choose between `php_win32_get_random_bytes()` (Windows) > or reading directly from `/dev/xrandom`. Ultimately you have to be prepared > to supplement the data (partially or fully) with calls to `php_rand()`. > Yes. It can be done this way. I would like to have full UUID implementation as well as other crypt features of OpenSSL. I made a RFC for building OpenSSL module by default. https://wiki.php.net/rfc/build-openssl-by-default I'll post it in new thread later. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1137f67cc9f52804f179857a--