generate random 64 bit client id integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinpkl
    New Member
    • Oct 2008
    • 41

    generate random 64 bit client id integer

    Hi

    How can i create a random client id which is 64 bit integer as described on this below link

    https://developers.goog le.com/analytics/devguides/collection/protocol/v1/email#client-id-cid

    thanks

    Vineet
  • computerfox
    Contributor
    • Mar 2010
    • 276

    #2
    The documentation describes a number of two sets of ten separated by a period.

    I could give you the answer, but I think you should give it a try.
    For the time being, here's something in Python:

    Code:
    #!/bin/python
    import random
    
    class generator:
     id=None;
    
     def __init__(self):
      self.id=self.gen();
    
     def gen(self):
      chars_raw="1,2,3,4,5,6,7,8,9,0";
      chars=chars_raw.split(",");
      final="";
      i=0;
      while i < 2:
       j=0;
       while j < 10:
        rand_index=random.randint(0,len(chars)-1);
        final=final+chars[rand_index];
        j+=1;
       if i==0:
        final=final+".";
       i+=1;
      return final;
    
    session=generator();
    print session.id;
    Last edited by computerfox; Jun 2 '15, 01:23 AM. Reason: Added citation

    Comment

    Working...