Skip to content

Commit

Permalink
Implement our own reset so it works properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyA committed Jun 18, 2009
1 parent e6b6be4 commit 534e1a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
13 changes: 11 additions & 2 deletions MD6.xs
Expand Up @@ -138,7 +138,7 @@ get_md6_ctx( pTHX_ SV * sv ) {
return ( md6_state * ) 0; /* some compilers insist on a return value */
}

static const char *
static char *
enc_hex( char *buf, const unsigned char *in, int bits ) {
static const char hx[] = "0123456789abcdef";
char *op = buf;
Expand All @@ -155,7 +155,7 @@ enc_hex( char *buf, const unsigned char *in, int bits ) {
return buf;
}

static const char *
static char *
enc_base64( char *buf, const unsigned char *in, int bits ) {
static const char b64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
Expand Down Expand Up @@ -280,6 +280,15 @@ DESTROY(context)
CODE:
Safefree(context);

void
reset(self)
SV* self
PREINIT:
md6_state* context = get_md6_ctx(aTHX_ self);
PPCODE:
MD6Init(context, context->d);
XSRETURN(1); /* self */

void
add(self, ...)
SV* self
Expand Down
15 changes: 15 additions & 0 deletions t/reset.t
@@ -0,0 +1,15 @@
#!perl

use strict;
use warnings;

use Digest::MD6;
use Test::More tests => 1;

my $d1 = Digest::MD6->new( 384 )->add( 'foo' )->hexdigest;
my $d2 = Digest::MD6->new( 384 )->add( 'bar' )->reset->add( 'foo' )
->hexdigest;
is $d1, $d2, 'reset';

# vim:ts=2:sw=2:et:ft=perl

0 comments on commit 534e1a2

Please sign in to comment.