• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • API Docs
    • Environments
    • Tutorials
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • Shifter »
    • Yogi »
    • YUI 2
    • YUI Doc »
    • YUI Test
    • YUI Website
    • YUI Compressor »
    • YUI Builder »
    • YUI PHP Loader
    • Grid Builder »
    • Skin Builder »
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    UUID (gallery-uuid) on cdn

    Last Updated: 01/23/12
    + 0 -

    Jeff Craig

    YUI Contributor

    See 8 more by this user.

    Created: 01/22/12
    Last CDN Push: 01/25/12
    Build Tag: gallery-2012.01.25-21-14
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.5.0pr1
    Free for use.

    A UUID Generator in JavaScript. This version uses Math.random and bitwise operations, so it should work in any environment, even a quite old one.

    Many pages have been written about why Math.random shouldn't be used for 'serious programming'. The points are well taken, Math.random is not guaranteed to be a cryptographically secure PRNG. If, for your usage, you need real guarantees, this version will not work, and you should do UUID generation server-side, which would allow you to generate UUIDs not using the PRNG version anyway. For my usage, this is 'good-enough', but you should evaluate that for your own application.

    There are a few improvements coming. The WHATWG has a proprosal for a window.crypto object, which, in addition to strongly-typed arrays, will allow this to work fast and more correctly, and with Loader's conditional loading, we can use that method in versions that support it.

    I am seriously considering writing a pure JS PRNG that will,while being dramatically slower, provide far more quality in the random-number generation, that the UUID generator could optionally use. Not as good a solution as window.crypto, but we'll see what the adoption curve on that feature looks like before I take this step.

    Future improvements:

    • Conditional Loading to optionally use a window.crypto version for better guarantees and speed
    • Optionally use a better PRNG than Math.random that will go into the Y.Crypto namespace

    • Tags:
    • foxxtrot
    • crypto
    • uuid
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    Code Sample

    <script src="http://yui.yahooapis.com/3.5.0pr1/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2012.01.25-21-14'
    }).use('gallery-uuid', function(Y) {
        var uuid = Y.Crypto.UUID();
    });

    © 2006-2013 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info