class Digest::Base
This abstract class provides a common interface to message digest implementation classes written in C.
Write a Digest subclass in C
Digest::Base provides a common interface to message digest classes written in C. These classes must provide a struct of type rb_digest_metadata_t: typedef int (rb_digest_hash_init_func_t)(void ); typedef void (rb_digest_hash_update_func_t)(void , unsigned char , size_t); typedef int (rb_digest_hash_finish_func_t)(void , unsigned char );
typedef struct {
int api_version;
size_t digest_len;
size_t block_len;
size_t ctx_size;
rb_digest_hash_init_func_t init_func;
rb_digest_hash_update_func_t update_func;
rb_digest_hash_finish_func_t finish_func;
} rb_digest_metadata_t;
This structure must be set as an instance variable named metadata (without the +@+ in front of the name). By example: static const rb_digest_metadata_t sha1 = { RUBY_DIGEST_API_VERSION, SHA1_DIGEST_LENGTH, SHA1_BLOCK_LENGTH, sizeof(SHA1_CTX), (rb_digest_hash_init_func_t)SHA1_Init, (rb_digest_hash_update_func_t)SHA1_Update, (rb_digest_hash_finish_func_t)SHA1_Finish, };
rb_ivar_set(cDigest_SHA1, rb_intern("metadata"), rb_digest_make_metadata(&sha1));
Public Instance Methods
(string) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/digest/0/digest.rbs, line 409
def <<: (string) -> self
Update the digest using given string and return self.
() → Integer
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/digest/0/digest.rbs, line 417
def block_length: () -> Integer
Return the block length of the digest in bytes.
() → Integer
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/digest/0/digest.rbs, line 425
def digest_length: () -> Integer
Return the length of the hash value in bytes.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/digest/0/digest.rbs, line 440
def finish: () -> String
(self) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/digest/0/digest.rbs, line 442
def initialize_copy: (self) -> self
() → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/digest/0/digest.rbs, line 433
def reset: () -> self
Reset the digest to its initial state and return self.