Ruby 2.4

Digest::Class

class Digest::Class

Parent:ObjectIncluded modules:Digest::Instance

该模块作为摘要实现类的基类。

公共类方法

base64digest(str, *args) Show source

返回给定字符串 的base64编码哈希值。返回值正确填充'='且不包含换行符。

# File ext/digest/lib/digest.rb, line 40 def self.base64digest(str, *args) [digest(str, *args)].pack('m0') end

Digest::Class.bubblebabble(string, ...) → hash_string Show source

返回给定字符串 的BubbleBabble编码哈希值。

static VALUE rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass) { return bubblebabble_str_new(rb_funcallv(klass, id_digest, argc, argv) }

Digest::Class.digest(string, *parameters) → hash_string Show source

返回给定字符串 的哈希值。这相当于Digest :: Instance#new.digest(string),其中额外的参数(如果有的话)被传递给构造函数,并且字符串 被传递给digest()。

static VALUE rb_digest_class_s_digest(int argc, VALUE *argv, VALUE klass) { VALUE str; volatile VALUE obj; if (argc < 1) { rb_raise(rb_eArgError, "no data given" } str = *argv++; argc--; StringValue(str obj = rb_obj_alloc(klass rb_obj_call_init(obj, argc, argv return rb_funcall(obj, id_digest, 1, str }

file(name, *args) Show source

创建摘要对象并读取给定的文件名称。可选参数传递给摘要类的构造函数。

p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"

# File ext/digest/lib/digest.rb, line 33 def self.file(name, *args) new(*args).file(name) end

Digest::Class.hexdigest(string, ...) → hash_string Show source

返回给定字符串 的十六进制编码的散列值。这几乎等同于Digest.hexencode(Digest :: Class.new(* parameters).digest(string))。

static VALUE rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass) { return hexencode_str_new(rb_funcallv(klass, id_digest, argc, argv) }