Beispiel #1
0
 /**
  * Creates a GlobalID from a $key and $salt.
  * 
  * @param $key the publicKey
  * @param $salt the salt
  * 
  * @return the GlobalID
  */
 public static function createGID($key, $salt)
 {
     $gid = null;
     $key = PublicKey::exportKey($key);
     // headers, trailers, and linebreaks have to be deleted
     $gid = strtoupper(hash_pbkdf2(self::$HASH_ALGORITHM, $key, $salt, self::$ITERATIONS));
     $gid = self::convBase($gid, "0123456789ABCDEF", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
     return $gid;
 }
Beispiel #2
0
 /**
  * Serialization method for SocialRecord
  * 
  * @return The serialized SocialRecord (String)
  */
 public function getJSONString()
 {
     $json = '{' . '"@context":"' . SocialRecord::JSONLD_CONTEXT . '",' . '"@type":"' . SocialRecord::JSONLD_TYPE . '",' . '"type":"' . $this->type . '",' . '"globalID":"' . $this->globalID . '",' . '"platformGID":"' . $this->platformGID . '",' . '"displayName":"' . $this->displayName . '",' . '"profileLocation":"' . $this->profileLocation . '",' . '"personalPublicKey":"' . PublicKey::exportKey($this->personalPublicKey) . '",' . '"accountPublicKey":"' . PublicKey::exportKey($this->accountPublicKey) . '",' . '"salt":"' . $this->salt . '",' . '"datetime":"' . $this->datetime . '",' . '"active":' . $this->active . ',' . '"keyRevocationList":[';
     foreach ($this->keyRevocationList as $krc) {
         $json .= $krc->getJSONString();
         if ($krc !== end($this->keyRevocationList)) {
             $json .= ',';
         }
     }
     $json .= ']}';
     return $json;
 }