Class: Digest::Base

Inherits:
Class
  • Object
show all
Defined in:
digest.c

Overview

This abstract class provides a common interface to message digest implementation classes written in C.

Direct Known Subclasses

MD5, RMD160, SHA1

Instance Method Summary collapse

Methods inherited from Class

base64digest, bubblebabble, digest, file, hexdigest, #initialize

Methods included from Instance

#==, #base64digest, #base64digest!, #bubblebabble, #digest, #digest!, #file, #hexdigest, #hexdigest!, #inspect, #length, #new, #size, #to_s

Constructor Details

This class inherits a constructor from Digest::Class

Instance Method Details

#<<Object

:nodoc:



571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'digest.c', line 571

static VALUE
rb_digest_base_update(VALUE self, VALUE str)
{
    rb_digest_metadata_t *algo;
    void *pctx;

    algo = get_digest_base_metadata(rb_obj_class(self));

    Data_Get_Struct(self, void, pctx);

    StringValue(str);
    algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));

    return self;
}

#block_lengthObject

:nodoc:



620
621
622
623
624
625
626
627
628
# File 'digest.c', line 620

static VALUE
rb_digest_base_block_length(VALUE self)
{
    rb_digest_metadata_t *algo;

    algo = get_digest_base_metadata(rb_obj_class(self));

    return INT2NUM(algo->block_len);
}

#digest_lengthObject

:nodoc:



609
610
611
612
613
614
615
616
617
# File 'digest.c', line 609

static VALUE
rb_digest_base_digest_length(VALUE self)
{
    rb_digest_metadata_t *algo;

    algo = get_digest_base_metadata(rb_obj_class(self));

    return INT2NUM(algo->digest_len);
}

#initialize_copyObject

:nodoc:



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'digest.c', line 535

static VALUE
rb_digest_base_copy(VALUE copy, VALUE obj)
{
    rb_digest_metadata_t *algo;
    void *pctx1, *pctx2;

    if (copy == obj) return copy;

    rb_check_frozen(copy);

    algo = get_digest_base_metadata(rb_obj_class(copy));

    Data_Get_Struct(obj, void, pctx1);
    Data_Get_Struct(copy, void, pctx2);
    memcpy(pctx2, pctx1, algo->ctx_size);

    return copy;
}

#resetObject

:nodoc:



555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'digest.c', line 555

static VALUE
rb_digest_base_reset(VALUE self)
{
    rb_digest_metadata_t *algo;
    void *pctx;

    algo = get_digest_base_metadata(rb_obj_class(self));

    Data_Get_Struct(self, void, pctx);

    algo->init_func(pctx);

    return self;
}

#updateObject

:nodoc:



571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'digest.c', line 571

static VALUE
rb_digest_base_update(VALUE self, VALUE str)
{
    rb_digest_metadata_t *algo;
    void *pctx;

    algo = get_digest_base_metadata(rb_obj_class(self));

    Data_Get_Struct(self, void, pctx);

    StringValue(str);
    algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));

    return self;
}