82f3a2db3f36b852c894692ef68802f87a43687b
[platform/framework/web/crosswalk-tizen.git] /
1 define(['./randHex', './choice'], function (randHex, choice) {
2
3   /**
4    * Returns pseudo-random guid (UUID v4)
5    * IMPORTANT: it's not totally "safe" since randHex/choice uses Math.random
6    * by default and sequences can be predicted in some cases. See the
7    * "random/random" documentation for more info about it and how to replace
8    * the default PRNG.
9    */
10   function guid() {
11     return (
12         randHex(8)+'-'+
13         randHex(4)+'-'+
14         // v4 UUID always contain "4" at this position to specify it was
15         // randomly generated
16         '4' + randHex(3) +'-'+
17         // v4 UUID always contain chars [a,b,8,9] at this position
18         choice(8, 9, 'a', 'b') + randHex(3)+'-'+
19         randHex(12)
20     );
21   }
22   return guid;
23 });