… | |
… | |
324 | |
324 | |
325 | # could be improved quite a bit in accuracy |
325 | # could be improved quite a bit in accuracy |
326 | NV |
326 | NV |
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 | |
356 | SV * |
358 | SV * |
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 | |
418 | int |
422 | int |
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 | |