Public feed
#600285
<?PHPclass Something{ public static function ReadExternal($data) { $content = explode( " ", base64_decode($data), 4); if (count($content) == 4) { $hmac = Utility::calculateHMAC("THE MAGIC NUMBER", $content[0] . " " . $content[1] . " " . $content[2]); if (base64_encode($hmac) === $content[3]) { // Set this donation object up! $instance = new Something(null); $instance->UserId = $content[1]; $instance->ProjectId = $content[2]; return $instance; } else { throw new SomethingException("HMAC did not match."); } } else { throw new SomethingException("Not enough data."); } return null; } public function WriteExternal() { $data = $this->UserId . " " . $this->ProjectId; $salt = uniqid(rand(), true); $message = $salt . " " . $data; $hmac = Utility::calculateHMAC(Keys::_SECRET,$message); $output = $message . " " . base64_encode($hmac); return base64_encode($output); } }?>