Class: Digest::SHA3

Inherits:
Base
  • Object
show all
Defined in:
lib/digest/sha3/version.rb,
ext/digest/sha3.c

Defined Under Namespace

Modules: Version

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'ext/digest/sha3.c', line 58

static VALUE
rb_sha3_initialize(int argc, VALUE *argv, VALUE self) {
	hashState *ctx;
	VALUE hashlen;
	int i_hashlen;

	if (rb_scan_args(argc, argv, "01", &hashlen) == 0) {
		i_hashlen = DEFAULT_DIGEST_LEN;
	} else {
		i_hashlen = NUM2INT(hashlen);
	}
	switch (i_hashlen) {
	case 0:
		rb_raise(rb_eArgError, "Unsupported hash length");
	case DEFAULT_DIGEST_LEN:
		break;
	default:
		Data_Get_Struct(self, hashState, ctx);
		sha3_init(ctx, i_hashlen);
	}

	return self;
}

Instance Method Details

#block_lengthObject



104
105
106
107
108
109
110
# File 'ext/digest/sha3.c', line 104

static VALUE
rb_sha3_block_length(VALUE self) {
	hashState *ctx;

	Data_Get_Struct(self, hashState, ctx);
	return INT2FIX(ctx->rate / 8);
}

#digest_lengthObject



96
97
98
99
100
101
102
# File 'ext/digest/sha3.c', line 96

static VALUE
rb_sha3_digest_length(VALUE self) {
	hashState *ctx;

	Data_Get_Struct(self, hashState, ctx);
	return INT2FIX(ctx->capacity / 2 / 8);
}