Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
OpenSSL::HMAC#hexdigest
hmac.hexdigest → string
ext/openssl/ossl_hmac.c
View on GitHub ↗
static VALUE
ossl_hmac_hexdigest(VALUE self)
{
EVP_MD_CTX *ctx;
unsigned char buf[EVP_MAX_MD_SIZE];
size_t buf_len = EVP_MAX_MD_SIZE;
VALUE ret;
GetHMAC(self, ctx);
if (EVP_DigestSignFinal(ctx, buf, &buf_len) != 1)
ossl_raise(eHMACError, "EVP_DigestSignFinal");
ret = rb_str_new(NULL, buf_len * 2);
ossl_bin2hex(buf, RSTRING_PTR(ret), buf_len);
return ret;
}
Returns the authentication code an instance represents as a hex-encoded string.
See also
.hexdigest
#digest
#initialize_copy
#base64digest
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0