Example #1
0
 public function testEncodeDecode()
 {
     $codec = $this->makeCodec();
     $payload = new Nife_StringBlob("Hello, world!");
     //$keyUrn = 'urn:bitprint:RPWPDCR73XTHHWTKZM6EWTCAYPIYSTIG.H2FMJSBMXRRHCNASUHMXRVTIXAN2QZPJB4VIZAY';
     $keyUrn = 'urn:sha1:RPWPDCR73XTHHWTKZM6EWTCAYPIYSTIG';
     $payloadThing = $codec->supportsInlinePayload() ? $payload : "urn:sha1:" . TOGoS_Base32::encode(hash('sha1', $payload, true));
     $sig = new TOGoS_RSAUtil_Signature($keyUrn, $payloadThing, "SHA1withRSA", "xyz123");
     // Obviously not a /valid/ signature.
     $blah = $codec->encode($sig);
     $this->assertTrue($blah instanceof Nife_Blob, "Encoded signature's not a Nife_Blob!");
     // Ensure no cheating!
     $blah = new Nife_StringBlob((string) $blah);
     $decoded = $codec->decode($blah);
     $this->assertEquals($sig->jsonSerialize(), $decoded->jsonSerialize());
 }
Example #2
0
 protected static function create2($privDer, $pubDer)
 {
     return new self($privDer, $pubDer, "urn:sha1:" . TOGoS_Base32::encode(hash('sha1', $pubDer, true)));
 }
Example #3
0
 protected function sha1Urn($sha1)
 {
     return "urn:sha1:" . TOGoS_Base32::encode($sha1);
 }
Example #4
0
 public function testEncoding()
 {
     foreach ($this->testIO as $in => $out) {
         $this->assertEquals($out, TOGoS_Base32::encode($in));
     }
 }
Example #5
0
 public function store($data)
 {
     $id = "urn:sha1:" . TOGoS_Base32::encode(hash('sha1', (string) $data, true));
     $this->store[$id] = Nife_Util::blob($data);
     return $id;
 }