File: C:/Ruby27-x64/share/doc/ruby/html/Digest/Class.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>class Digest::Class - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "../";
var index_rel_prefix = "../";
</script>
<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="../index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="../table_of_contents.html#pages">Pages</a>
<a href="../table_of_contents.html#classes">Classes</a>
<a href="../table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<p class="link"><a href="../Object.html">Object</a>
</div>
<div id="includes-section" class="nav-section">
<h3>Included Modules</h3>
<ul class="link-list">
<li><a class="include" href="Instance.html">Digest::Instance</a>
</ul>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-base64digest">::base64digest</a>
<li ><a href="#method-c-bubblebabble">::bubblebabble</a>
<li ><a href="#method-c-digest">::digest</a>
<li ><a href="#method-c-file">::file</a>
<li ><a href="#method-c-hexdigest">::hexdigest</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="class-Digest::Class">
<h1 id="class-Digest::Class" class="class">
class Digest::Class
</h1>
<section class="description">
<p>This module stands as a base class for digest implementation classes.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-base64digest" class="method-detail ">
<div class="method-heading">
<span class="method-name">base64digest</span><span
class="method-args">(str, *args)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns the base64 encoded hash value of a given <em>string</em>. The return value is properly padded with '=' and contains no line feeds.</p>
<div class="method-source-code" id="base64digest-source">
<pre><span class="ruby-comment"># File ext/digest/lib/digest.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">base64digest</span>(<span class="ruby-identifier">str</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
[<span class="ruby-identifier">digest</span>(<span class="ruby-identifier">str</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)].<span class="ruby-identifier">pack</span>(<span class="ruby-string">'m0'</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-c-bubblebabble" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
Digest::Class.bubblebabble(string, ...) → hash_string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns the BubbleBabble encoded hash value of a given <em>string</em>.</p>
<div class="method-source-code" id="bubblebabble-source">
<pre>static VALUE
rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass)
{
return bubblebabble_str_new(rb_funcallv(klass, id_digest, argc, argv));
}</pre>
</div>
</div>
</div>
<div id="method-c-digest" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
Digest::Class.digest(string, *parameters) → hash_string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns the hash value of a given <em>string</em>. This is equivalent to <a href="Instance.html#method-i-new"><code>Digest::Class.new(*parameters)</code></a>.digest(string), where extra <em>parameters</em>, if any, are passed through to the constructor and the <em>string</em> is passed to <a href="Instance.html#method-i-digest"><code>digest()</code></a>.</p>
<div class="method-source-code" id="digest-source">
<pre>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);
}</pre>
</div>
</div>
</div>
<div id="method-c-file" class="method-detail ">
<div class="method-heading">
<span class="method-name">file</span><span
class="method-args">(name, *args)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Creates a digest object and reads a given file, <em>name</em>. Optional arguments are passed to the constructor of the digest class.</p>
<pre class="ruby"><span class="ruby-identifier">p</span> <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA256</span>.<span class="ruby-identifier">file</span>(<span class="ruby-string">"X11R6.8.2-src.tar.bz2"</span>).<span class="ruby-identifier">hexdigest</span>
<span class="ruby-comment"># => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"</span>
</pre>
<div class="method-source-code" id="file-source">
<pre><span class="ruby-comment"># File ext/digest/lib/digest.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">file</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>).<span class="ruby-identifier">file</span>(<span class="ruby-identifier">name</span>)
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div id="method-c-hexdigest" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
Digest::Class.hexdigest(string[, ...]) → hash_string
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Returns the hex-encoded hash value of a given <em>string</em>. This is almost equivalent to <a href="../Digest.html#method-c-hexencode"><code>Digest.hexencode</code></a>(<a href="Instance.html#method-i-new"><code>Digest::Class.new(*parameters)</code></a>.digest(string)).</p>
<div class="method-source-code" id="hexdigest-source">
<pre>static VALUE
rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass)
{
return hexencode_str_new(rb_funcallv(klass, id_digest, argc, argv));
}</pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>