ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Digest-Hashcash/Hashcash.xs
(Generate patch)

Comparing Digest-Hashcash/Hashcash.xs (file contents):
Revision 1.2 by root, Sun Sep 7 00:58:23 2003 UTC vs.
Revision 1.3 by root, Thu Sep 11 06:20:26 2003 UTC

324 324
325# could be improved quite a bit in accuracy 325# could be improved quite a bit in accuracy
326NV 326NV
327_estimate_rounds () 327_estimate_rounds ()
328 CODE: 328 CODE:
329{
329 char data[40]; 330 char data[40];
330 NVTime nvtime = get_nvtime (); 331 NVTime nvtime = get_nvtime ();
331 NV t1, t2, t; 332 NV t1, t2, t;
332 int count = 0; 333 int count = 0;
333 SHA_INFO ctx; 334 SHA_INFO ctx;
348 t2 = nvtime (); 349 t2 = nvtime ();
349 350
350 } while (t == t2); 351 } while (t == t2);
351 352
352 RETVAL = (NV)count / (t2 - t1); 353 RETVAL = (NV)count / (t2 - t1);
354}
353 OUTPUT: 355 OUTPUT:
354 RETVAL 356 RETVAL
355 357
356SV * 358SV *
357_gentoken (int size, IV timestamp, char *resource, char *trial = "", int extrarand = 0) 359_gentoken (int size, IV timestamp, char *resource, char *trial = "", int extrarand = 0)
358 CODE: 360 CODE:
361{
359 SHA_INFO ctx1, ctx; 362 SHA_INFO ctx1, ctx;
360 char *token, *seq, *s; 363 char *token, *seq, *s;
361 int toklen, i; 364 int toklen, i;
362 time_t tstamp = timestamp ? timestamp : time (0); 365 time_t tstamp = timestamp ? timestamp : time (0);
363 struct tm *tm = gmtime (&tstamp); 366 struct tm *tm = gmtime (&tstamp);
410 *s = nextenc [*s]; 413 *s = nextenc [*s];
411 } while (*s++ == 'a'); 414 } while (*s++ == 'a');
412 } 415 }
413 416
414 RETVAL = newSVpvn (token, toklen); 417 RETVAL = newSVpvn (token, toklen);
418}
415 OUTPUT: 419 OUTPUT:
416 RETVAL 420 RETVAL
417 421
418int 422int
419_prefixlen (SV *tok) 423_prefixlen (SV *tok)
420 CODE: 424 CODE:
425{
421 STRLEN toklen; 426 STRLEN toklen;
422 char *token = SvPV (tok, toklen); 427 char *token = SvPV (tok, toklen);
423 SHA_INFO ctx; 428 SHA_INFO ctx;
424 429
425 sha_init (&ctx); 430 sha_init (&ctx);
426 sha_update (&ctx, token, toklen); 431 sha_update (&ctx, token, toklen);
427 RETVAL = sha_final (&ctx); 432 RETVAL = sha_final (&ctx);
433}
428 OUTPUT: 434 OUTPUT:
429 RETVAL 435 RETVAL
430 436
431 437

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines