Guest User

Untitled

a guest
Apr 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. QUuid QUuid::createUuidV3OrV5(const QUuid &ns, const QByteArray &name, Version v)
  2. {
  3.     QUuid result;
  4.     QByteArray tmp;
  5.     {
  6.         QCryptographicHash hash(QCryptographicHash::Md5);
  7.         hash.addData(ns.toRfc4122());
  8.         hash.addData(name);
  9.  
  10.         tmp = hash.result();
  11.         tmp.resize(16);
  12.     }
  13.  
  14.     result = QUuid::fromRfc4122(tmp);
  15.  
  16.     result.data3 &= 0x0FFF;
  17.     result.data3 |= ((int)v << 12);
  18.     result.data4[0] &= 0x3F;
  19.     result.data4[0] |= 0x80;
  20.  
  21.     return result;
  22. }
Add Comment
Please, Sign In to add comment