blob: f97de9dd57340e37fc409d430167cb94bcdec3b5 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>SimpleHash (Apache Shiro :: Cryptography :: Hashing 1.9.1 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../jquery/jquery-3.5.1.js"></script>
<script type="text/javascript" src="../../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="SimpleHash (Apache Shiro :: Cryptography :: Hashing 1.9.1 API)";
}
}
catch(err) {
}
//-->
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10,"i14":10,"i15":10,"i16":10,"i17":10,"i18":10,"i19":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav"><!-- Matomo --> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ /* We explicitly disable cookie tracking to avoid privacy issues */ _paq.push(['disableCookies']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//matomo.privacy.apache.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '2']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code -->
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/SimpleHash.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.apache.shiro.crypto.hash</a></div>
<h2 title="Class SimpleHash" class="title">Class SimpleHash</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.shiro.codec.CodecSupport</li>
<li>
<ul class="inheritance">
<li><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">org.apache.shiro.crypto.hash.AbstractHash</a></li>
<li>
<ul class="inheritance">
<li>org.apache.shiro.crypto.hash.SimpleHash</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io" class="externalLink">Serializable</a></code>, <code><a href="Hash.html" title="interface in org.apache.shiro.crypto.hash">Hash</a></code>, <code>org.apache.shiro.util.ByteSource</code></dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="Md2Hash.html" title="class in org.apache.shiro.crypto.hash">Md2Hash</a></code>, <code><a href="Md5Hash.html" title="class in org.apache.shiro.crypto.hash">Md5Hash</a></code>, <code><a href="Sha1Hash.html" title="class in org.apache.shiro.crypto.hash">Sha1Hash</a></code>, <code><a href="Sha256Hash.html" title="class in org.apache.shiro.crypto.hash">Sha256Hash</a></code>, <code><a href="Sha384Hash.html" title="class in org.apache.shiro.crypto.hash">Sha384Hash</a></code>, <code><a href="Sha512Hash.html" title="class in org.apache.shiro.crypto.hash">Sha512Hash</a></code></dd>
</dl>
<hr>
<pre>public class <a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.43">SimpleHash</a>
extends <a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></pre>
<div class="block">A <code>Hash</code> implementation that allows any <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to
be used. This class is a less type-safe variant than the other <code>AbstractHash</code> subclasses
(e.g. <a href="Sha512Hash.html" title="class in org.apache.shiro.crypto.hash"><code>Sha512Hash</code></a>, etc), but it does allow for any algorithm name to be specified in case the other subclass
implementations do not represent an algorithm that you may want to use.
<p/>
As of Shiro 1.1, this class effectively replaces the (now-deprecated) <a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash"><code>AbstractHash</code></a> class. It subclasses
<code>AbstractHash</code> only to retain backwards-compatibility.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../serialized-form.html#org.apache.shiro.crypto.hash.SimpleHash">Serialized Form</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<ul class="blockList">
<li class="blockList"><a id="nested.classes.inherited.from.class.org.apache.shiro.util.ByteSource">
<!-- -->
</a>
<h3>Nested classes/interfaces inherited from interface&nbsp;org.apache.shiro.util.ByteSource</h3>
<code>org.apache.shiro.util.ByteSource.Util</code></li>
</ul>
</li>
</ul>
</section>
<!-- =========== FIELD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<ul class="blockList">
<li class="blockList"><a id="fields.inherited.from.class.org.apache.shiro.codec.CodecSupport">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;org.apache.shiro.codec.CodecSupport</h3>
<code>PREFERRED_ENCODING</code></li>
</ul>
</li>
</ul>
</section>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String)">SimpleHash</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName)</code></th>
<td class="colLast">
<div class="block">Creates an new instance with only its <code>algorithmName</code> set - no hashing is performed.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.Object)">SimpleHash</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source)</code></th>
<td class="colLast">
<div class="block">Creates an <code>algorithmName</code>-specific hash of the specified <code>source</code> with no <code>salt</code> using a
single hash iteration.</div>
</td>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.Object,java.lang.Object)">SimpleHash</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;salt)</code></th>
<td class="colLast">
<div class="block">Creates an <code>algorithmName</code>-specific hash of the specified <code>source</code> using the given <code>salt</code>
using a single hash iteration.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(java.lang.String,java.lang.Object,java.lang.Object,int)">SimpleHash</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;salt,
int&nbsp;hashIterations)</code></th>
<td class="colLast">
<div class="block">Creates an <code>algorithmName</code>-specific hash of the specified <code>source</code> using the given
<code>salt</code> a total of <code>hashIterations</code> times.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>
<!-- ========== METHOD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>protected org.apache.shiro.util.ByteSource</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#convertSaltToBytes(java.lang.Object)">convertSaltToBytes</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;salt)</code></th>
<td class="colLast">
<div class="block">Acquires the specified <code>salt</code> argument's bytes and returns them in the form of a <code>ByteSource</code> instance.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>protected org.apache.shiro.util.ByteSource</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#convertSourceToBytes(java.lang.Object)">convertSourceToBytes</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source)</code></th>
<td class="colLast">
<div class="block">Acquires the specified <code>source</code> argument's bytes and returns them in the form of a <code>ByteSource</code> instance.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#equals(java.lang.Object)">equals</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;o)</code></th>
<td class="colLast">
<div class="block">Returns <code>true</code> if the specified object is a Hash and its <a href="#getBytes()"><code>byte array</code></a> is identical to
this Hash's byte array, <code>false</code> otherwise.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getAlgorithmName()">getAlgorithmName</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when performing the hash.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getBytes()">getBytes</a></span>()</code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>protected <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink">MessageDigest</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getDigest(java.lang.String)">getDigest</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName)</code></th>
<td class="colLast">
<div class="block">Returns the JDK MessageDigest instance to use for executing the hash.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getIterations()">getIterations</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns the number of hash iterations used to compute the hash.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>org.apache.shiro.util.ByteSource</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSalt()">getSalt</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a salt used to compute the hash or <code>null</code> if no salt was used.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>protected byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hash(byte%5B%5D)">hash</a></span>&#8203;(byte[]&nbsp;bytes)</code></th>
<td class="colLast">
<div class="block">Hashes the specified byte array without a salt for a single iteration.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>protected byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hash(byte%5B%5D,byte%5B%5D)">hash</a></span>&#8203;(byte[]&nbsp;bytes,
byte[]&nbsp;salt)</code></th>
<td class="colLast">
<div class="block">Hashes the specified byte array using the given <code>salt</code> for a single iteration.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>protected byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hash(byte%5B%5D,byte%5B%5D,int)">hash</a></span>&#8203;(byte[]&nbsp;bytes,
byte[]&nbsp;salt,
int&nbsp;hashIterations)</code></th>
<td class="colLast">
<div class="block">Hashes the specified byte array using the given <code>salt</code> for the specified number of iterations.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>int</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#hashCode()">hashCode</a></span>()</code></th>
<td class="colLast">
<div class="block">Simply returns toHex().hashCode();</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isEmpty()">isEmpty</a></span>()</code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setBytes(byte%5B%5D)">setBytes</a></span>&#8203;(byte[]&nbsp;alreadyHashedBytes)</code></th>
<td class="colLast">
<div class="block">Sets the raw bytes stored by this hash instance.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setIterations(int)">setIterations</a></span>&#8203;(int&nbsp;iterations)</code></th>
<td class="colLast">
<div class="block">Sets the iterations used to previously compute AN ALREADY GENERATED HASH.</div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setSalt(org.apache.shiro.util.ByteSource)">setSalt</a></span>&#8203;(org.apache.shiro.util.ByteSource&nbsp;salt)</code></th>
<td class="colLast">
<div class="block">Sets the salt used to previously compute AN ALREADY GENERATED HASH.</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toBase64()">toBase64</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a Base64-encoded string of the underlying <a href="#getBytes()"><code>byte array</code></a>.</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>protected org.apache.shiro.util.ByteSource</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toByteSource(java.lang.Object)">toByteSource</a></span>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;o)</code></th>
<td class="colLast">
<div class="block">Converts a given object into a <code>ByteSource</code> instance.</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toHex()">toHex</a></span>()</code></th>
<td class="colLast">
<div class="block">Returns a hex-encoded string of the underlying <a href="#getBytes()"><code>byte array</code></a>.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toString()">toString</a></span>()</code></th>
<td class="colLast">
<div class="block">Simple implementation that merely returns <a href="#toHex()"><code>toHex()</code></a>.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.org.apache.shiro.codec.CodecSupport">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.shiro.codec.CodecSupport</h3>
<code>isByteSource, objectToBytes, objectToString, toBytes, toBytes, toBytes, toBytes, toBytes, toBytes, toBytes, toChars, toChars, toString, toString, toString</code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang" class="externalLink">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang" class="externalLink">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang" class="externalLink">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang" class="externalLink">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang" class="externalLink">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait(long,int)" title="class or interface in java.lang" class="externalLink">wait</a></code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a id="&lt;init&gt;(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SimpleHash</h4>
<pre>public&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.92">SimpleHash</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName)</pre>
<div class="block">Creates an new instance with only its <code>algorithmName</code> set - no hashing is performed.
<p/>
Because all other constructors in this class hash the <code>source</code> constructor argument, this
constructor is useful in scenarios when you have a byte array that you know is already hashed and
just want to set the bytes in their raw form directly on an instance. After using this constructor,
you can then immediately call <a href="#setBytes(byte%5B%5D)"><code>setBytes</code></a> to have a fully-initialized instance.
<p/>
<b>N.B.</b>The algorithm identified by the <code>algorithmName</code> parameter must be available on the JVM. If it
is not, a <code>UnknownAlgorithmException</code> will be thrown when the hash is performed (not at instantiation).</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>algorithmName</code> - the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when
performing the hash.</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><code>UnknownAlgorithmException</code></dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(java.lang.String,java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SimpleHash</h4>
<pre>public&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.115">SimpleHash</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source)
throws org.apache.shiro.codec.CodecException,
org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Creates an <code>algorithmName</code>-specific hash of the specified <code>source</code> with no <code>salt</code> using a
single hash iteration.
<p/>
This is a convenience constructor that merely executes <code>this( algorithmName, source, null, 1);</code>.
<p/>
Please see the
<a href="#%3Cinit%3E(java.lang.String,java.lang.Object,java.lang.Object,int)"><code>SimpleHashHash(algorithmName, Object,Object,int)</code></a>
constructor for the types of Objects that may be passed into this constructor, as well as how to support further
types.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>algorithmName</code> - the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when
performing the hash.</dd>
<dd><code>source</code> - the object to be hashed.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.codec.CodecException</code> - if the specified <code>source</code> cannot be converted into a byte array (byte[]).</dd>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the <code>algorithmName</code> is not available.</dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(java.lang.String,java.lang.Object,java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SimpleHash</h4>
<pre>public&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.138">SimpleHash</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;salt)
throws org.apache.shiro.codec.CodecException,
org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Creates an <code>algorithmName</code>-specific hash of the specified <code>source</code> using the given <code>salt</code>
using a single hash iteration.
<p/>
It is a convenience constructor that merely executes <code>this( algorithmName, source, salt, 1);</code>.
<p/>
Please see the
<a href="#%3Cinit%3E(java.lang.String,java.lang.Object,java.lang.Object,int)"><code>SimpleHashHash(algorithmName, Object,Object,int)</code></a>
constructor for the types of Objects that may be passed into this constructor, as well as how to support further
types.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>algorithmName</code> - the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when
performing the hash.</dd>
<dd><code>source</code> - the source object to be hashed.</dd>
<dd><code>salt</code> - the salt to use for the hash</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.codec.CodecException</code> - if either constructor argument cannot be converted into a byte array.</dd>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the <code>algorithmName</code> is not available.</dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(java.lang.String,java.lang.Object,java.lang.Object,int)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>SimpleHash</h4>
<pre>public&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.165">SimpleHash</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;salt,
int&nbsp;hashIterations)
throws org.apache.shiro.codec.CodecException,
org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Creates an <code>algorithmName</code>-specific hash of the specified <code>source</code> using the given
<code>salt</code> a total of <code>hashIterations</code> times.
<p/>
By default, this class only supports Object method arguments of
type <code>byte[]</code>, <code>char[]</code>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink"><code>String</code></a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io" class="externalLink"><code>File</code></a>,
<a href="https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io" class="externalLink"><code>InputStream</code></a> or <code>ByteSource</code>. If either
argument is anything other than these types a <code>CodecException</code>
will be thrown.
<p/>
If you want to be able to hash other object types, or use other salt types, you need to override the
<code>toBytes(Object)</code> method to support those specific types. Your other option is to
convert your arguments to one of the default supported types first before passing them in to this
constructor}.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>algorithmName</code> - the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when
performing the hash.</dd>
<dd><code>source</code> - the source object to be hashed.</dd>
<dd><code>salt</code> - the salt to use for the hash</dd>
<dd><code>hashIterations</code> - the number of times the <code>source</code> argument hashed for attack resiliency.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.codec.CodecException</code> - if either Object constructor argument cannot be converted into a byte array.</dd>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the <code>algorithmName</code> is not available.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
<!-- ============ METHOD DETAIL ========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="convertSourceToBytes(java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>convertSourceToBytes</h4>
<pre class="methodSignature">protected&nbsp;org.apache.shiro.util.ByteSource&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.191">convertSourceToBytes</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;source)</pre>
<div class="block">Acquires the specified <code>source</code> argument's bytes and returns them in the form of a <code>ByteSource</code> instance.
<p/>
This implementation merely delegates to the convenience <a href="#toByteSource(java.lang.Object)"><code>toByteSource(Object)</code></a> method for generic
conversion. Can be overridden by subclasses for source-specific conversion.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>source</code> - the source object to be hashed.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the source's bytes in the form of a <code>ByteSource</code> instance.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a id="convertSaltToBytes(java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>convertSaltToBytes</h4>
<pre class="methodSignature">protected&nbsp;org.apache.shiro.util.ByteSource&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.205">convertSaltToBytes</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;salt)</pre>
<div class="block">Acquires the specified <code>salt</code> argument's bytes and returns them in the form of a <code>ByteSource</code> instance.
<p/>
This implementation merely delegates to the convenience <a href="#toByteSource(java.lang.Object)"><code>toByteSource(Object)</code></a> method for generic
conversion. Can be overridden by subclasses for salt-specific conversion.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>salt</code> - the salt to be use for the hash.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the salt's bytes in the form of a <code>ByteSource</code> instance.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a id="toByteSource(java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toByteSource</h4>
<pre class="methodSignature">protected&nbsp;org.apache.shiro.util.ByteSource&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.216">toByteSource</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;o)</pre>
<div class="block">Converts a given object into a <code>ByteSource</code> instance. Assumes the object can be converted to bytes.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>o</code> - the Object to convert into a <code>ByteSource</code> instance.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <code>ByteSource</code> representation of the specified object's bytes.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a id="getAlgorithmName()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getAlgorithmName</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.238">getAlgorithmName</a>()</pre>
<div class="block">Returns the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when performing the hash.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="Hash.html#getAlgorithmName()">getAlgorithmName</a></code>&nbsp;in interface&nbsp;<code><a href="Hash.html" title="interface in org.apache.shiro.crypto.hash">Hash</a></code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="AbstractHash.html#getAlgorithmName()">getAlgorithmName</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink"><code>MessageDigest</code></a> algorithm name to use when performing the hash.</dd>
</dl>
</li>
</ul>
<a id="getSalt()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSalt</h4>
<pre class="methodSignature">public&nbsp;org.apache.shiro.util.ByteSource&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.242">getSalt</a>()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="Hash.html#getSalt()">Hash</a></code></span></div>
<div class="block">Returns a salt used to compute the hash or <code>null</code> if no salt was used.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a salt used to compute the hash or <code>null</code> if no salt was used.</dd>
</dl>
</li>
</ul>
<a id="getIterations()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getIterations</h4>
<pre class="methodSignature">public&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.246">getIterations</a>()</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="Hash.html#getIterations()">Hash</a></code></span></div>
<div class="block">Returns the number of hash iterations used to compute the hash.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the number of hash iterations used to compute the hash.</dd>
</dl>
</li>
</ul>
<a id="getBytes()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getBytes</h4>
<pre class="methodSignature">public&nbsp;byte[]&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.250">getBytes</a>()</pre>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>getBytes</code>&nbsp;in interface&nbsp;<code>org.apache.shiro.util.ByteSource</code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#getBytes()">getBytes</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
</dl>
</li>
</ul>
<a id="setBytes(byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setBytes</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.262">setBytes</a>&#8203;(byte[]&nbsp;alreadyHashedBytes)</pre>
<div class="block">Sets the raw bytes stored by this hash instance.
<p/>
The bytes are kept in raw form - they will not be hashed/changed. This is primarily a utility method for
constructing a Hash instance when the hashed value is already known.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#setBytes(byte%5B%5D)">setBytes</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>alreadyHashedBytes</code> - the raw already-hashed bytes to store in this instance.</dd>
</dl>
</li>
</ul>
<a id="setIterations(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setIterations</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.277">setIterations</a>&#8203;(int&nbsp;iterations)</pre>
<div class="block">Sets the iterations used to previously compute AN ALREADY GENERATED HASH.
<p/>
This is provided <em>ONLY</em> to reconstitute an already-created Hash instance. It should ONLY ever be
invoked when re-constructing a hash instance from an already-hashed value.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>iterations</code> - the number of hash iterations used to previously create the hash/digest.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a id="setSalt(org.apache.shiro.util.ByteSource)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setSalt</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.290">setSalt</a>&#8203;(org.apache.shiro.util.ByteSource&nbsp;salt)</pre>
<div class="block">Sets the salt used to previously compute AN ALREADY GENERATED HASH.
<p/>
This is provided <em>ONLY</em> to reconstitute a Hash instance that has already been computed. It should ONLY
ever be invoked when re-constructing a hash instance from an already-hashed value.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>salt</code> - the salt used to previously create the hash/digest.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a id="getDigest(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDigest</h4>
<pre class="methodSignature">protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security" class="externalLink">MessageDigest</a>&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.301">getDigest</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;algorithmName)
throws org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Returns the JDK MessageDigest instance to use for executing the hash.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#getDigest(java.lang.String)">getDigest</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>algorithmName</code> - the algorithm to use for the hash, provided by subclasses.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the MessageDigest object for the specified <code>algorithm</code>.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the specified algorithm name is not available.</dd>
</dl>
</li>
</ul>
<a id="hash(byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hash</h4>
<pre class="methodSignature">protected&nbsp;byte[]&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.317">hash</a>&#8203;(byte[]&nbsp;bytes)
throws org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Hashes the specified byte array without a salt for a single iteration.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#hash(byte%5B%5D)">hash</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>bytes</code> - the bytes to hash.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the hashed bytes.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the configured <a href="#getAlgorithmName()"><code>algorithmName</code></a> is not available.</dd>
</dl>
</li>
</ul>
<a id="hash(byte[],byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hash</h4>
<pre class="methodSignature">protected&nbsp;byte[]&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.329">hash</a>&#8203;(byte[]&nbsp;bytes,
byte[]&nbsp;salt)
throws org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Hashes the specified byte array using the given <code>salt</code> for a single iteration.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#hash(byte%5B%5D,byte%5B%5D)">hash</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>bytes</code> - the bytes to hash</dd>
<dd><code>salt</code> - the salt to use for the initial hash</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the hashed bytes</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the configured <a href="#getAlgorithmName()"><code>algorithmName</code></a> is not available.</dd>
</dl>
</li>
</ul>
<a id="hash(byte[],byte[],int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hash</h4>
<pre class="methodSignature">protected&nbsp;byte[]&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.342">hash</a>&#8203;(byte[]&nbsp;bytes,
byte[]&nbsp;salt,
int&nbsp;hashIterations)
throws org.apache.shiro.crypto.UnknownAlgorithmException</pre>
<div class="block">Hashes the specified byte array using the given <code>salt</code> for the specified number of iterations.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#hash(byte%5B%5D,byte%5B%5D,int)">hash</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>bytes</code> - the bytes to hash</dd>
<dd><code>salt</code> - the salt to use for the initial hash</dd>
<dd><code>hashIterations</code> - the number of times the the <code>bytes</code> will be hashed (for attack resiliency).</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the hashed bytes.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>org.apache.shiro.crypto.UnknownAlgorithmException</code> - if the <a href="#getAlgorithmName()"><code>algorithmName</code></a> is not available.</dd>
</dl>
</li>
</ul>
<a id="isEmpty()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isEmpty</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.358">isEmpty</a>()</pre>
</li>
</ul>
<a id="toHex()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toHex</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.371">toHex</a>()</pre>
<div class="block">Returns a hex-encoded string of the underlying <a href="#getBytes()"><code>byte array</code></a>.
<p/>
This implementation caches the resulting hex string so multiple calls to this method remain efficient.
However, calling <a href="#setBytes(byte%5B%5D)"><code>setBytes</code></a> will null the cached value, forcing it to be recalculated the
next time this method is called.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>toHex</code>&nbsp;in interface&nbsp;<code>org.apache.shiro.util.ByteSource</code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#toHex()">toHex</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a hex-encoded string of the underlying <a href="#getBytes()"><code>byte array</code></a>.</dd>
</dl>
</li>
</ul>
<a id="toBase64()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toBase64</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.387">toBase64</a>()</pre>
<div class="block">Returns a Base64-encoded string of the underlying <a href="#getBytes()"><code>byte array</code></a>.
<p/>
This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
However, calling <a href="#setBytes(byte%5B%5D)"><code>setBytes</code></a> will null the cached value, forcing it to be recalculated the
next time this method is called.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>toBase64</code>&nbsp;in interface&nbsp;<code>org.apache.shiro.util.ByteSource</code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#toBase64()">toBase64</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a Base64-encoded string of the underlying <a href="#getBytes()"><code>byte array</code></a>.</dd>
</dl>
</li>
</ul>
<a id="toString()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toString</h4>
<pre class="methodSignature">public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.400">toString</a>()</pre>
<div class="block">Simple implementation that merely returns <a href="#toHex()"><code>toHex()</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#toString()">toString</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the <a href="#toHex()"><code>toHex()</code></a> value.</dd>
</dl>
</li>
</ul>
<a id="equals(java.lang.Object)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.412">equals</a>&#8203;(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>&nbsp;o)</pre>
<div class="block">Returns <code>true</code> if the specified object is a Hash and its <a href="#getBytes()"><code>byte array</code></a> is identical to
this Hash's byte array, <code>false</code> otherwise.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#equals(java.lang.Object)">equals</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>o</code> - the object (Hash) to check for equality.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if the specified object is a Hash and its <a href="#getBytes()"><code>byte array</code></a> is identical to
this Hash's byte array, <code>false</code> otherwise.</dd>
</dl>
</li>
</ul>
<a id="hashCode()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>hashCode</h4>
<pre class="methodSignature">public&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/shiro/crypto/hash/SimpleHash.html#line.425">hashCode</a>()</pre>
<div class="block">Simply returns toHex().hashCode();</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="AbstractHash.html#hashCode()">hashCode</a></code>&nbsp;in class&nbsp;<code><a href="AbstractHash.html" title="class in org.apache.shiro.crypto.hash">AbstractHash</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>toHex().hashCode()</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/SimpleHash.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small>Copyright &#169; 2004&#x2013;2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</footer>
</body>
</html>