/** * Creates a signature string for use with recurly.js * * @param array $data * * @throws \InvalidArgumentException * @return string */ public function sign(array $data) { if (null === $this->privateKey) { throw new \InvalidArgumentException('No privateKey set'); } $data += ['nonce' => md5(uniqid()), 'timestamp' => time()]; $query = http_build_query($data); return Hasher::hash($query, $this->privateKey) . '|' . $query; }
public function testHash() { $this->assertEquals('85d155c55ed286a300bd1cf124de08d87e914f3a', Hasher::hash('foo', 'bar')); }