title: Windows8: device identifier
body: <p>I am currently trying to retrieve a unique device identifier. Here is my code:</p>
  
  <pre><code>var token = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(null);
  var reader = Windows.Storage.Streams.DataReader.fromBuffer(token.id);
  
  reader.unicodeEncoding = true;
  var identifier = reader.readString(reader.unconsumedBufferLength);
  
  console.log(identifier);
  </code></pre>
  
  <p>But it raises following error:</p>
  
  <blockquote>
    <p>The operation attempted to access data outside the valid range.</p>
  </blockquote>
  
  <p>How can I retrieve the size of my <em>token.id</em> string? I also tried to use <em>token.id.length</em>, but result is the same.</p>