Class Index | File Index

Classes


Class KJUR.crypto.MessageDigest

MessageDigest class which is very similar to java.security.MessageDigest class
Defined in: crypto-1.1.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
MessageDigest class which is very similar to java.security.MessageDigest class
Currently this supports following algorithm and providers combination:
  • md5 - cryptojs
  • sha1 - cryptojs
  • sha224 - cryptojs
  • sha256 - cryptojs
  • sha384 - cryptojs
  • sha512 - cryptojs
  • ripemd160 - cryptojs
  • sha256 - sjcl (NEW from crypto.js 1.0.4)
Method Summary
Method Attributes Method Name and Description
<static>  
KJUR.crypto.MessageDigest.digest()
completes hash calculation and returns hash result
<static>  
KJUR.crypto.MessageDigest.digestHex(hex)
performs final update on the digest using hexadecimal string, then completes the digest computation
<static>  
KJUR.crypto.MessageDigest.digestString(str)
performs final update on the digest using string, then completes the digest computation
<static>  
KJUR.crypto.MessageDigest.setAlgAndProvider(alg, prov)
set hash algorithm and provider
<static>  
KJUR.crypto.MessageDigest.updateHex(hex)
update digest by specified hexadecimal string
<static>  
KJUR.crypto.MessageDigest.updateString(str)
update digest by specified string
Class Detail
KJUR.crypto.MessageDigest(params)
MessageDigest class which is very similar to java.security.MessageDigest class
Currently this supports following algorithm and providers combination:
  • md5 - cryptojs
  • sha1 - cryptojs
  • sha224 - cryptojs
  • sha256 - cryptojs
  • sha384 - cryptojs
  • sha512 - cryptojs
  • ripemd160 - cryptojs
  • sha256 - sjcl (NEW from crypto.js 1.0.4)
// CryptoJS provider sample
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha1.js"></script>
<script src="crypto-1.0.js"></script>
var md = new KJUR.crypto.MessageDigest({alg: "sha1", prov: "cryptojs"});
md.updateString('aaa')
var mdHex = md.digest()

// SJCL(Stanford JavaScript Crypto Library) provider sample
<script src="http://bitwiseshiftleft.github.io/sjcl/sjcl.js"></script>
<script src="crypto-1.0.js"></script>
var md = new KJUR.crypto.MessageDigest({alg: "sha256", prov: "sjcl"}); // sjcl supports sha256 only
md.updateString('aaa')
var mdHex = md.digest()
Parameters:
{Array} params
parameters for constructor
Method Detail
<static> KJUR.crypto.MessageDigest.digest()
completes hash calculation and returns hash result
md.digest()

<static> KJUR.crypto.MessageDigest.digestHex(hex)
performs final update on the digest using hexadecimal string, then completes the digest computation
md.digestHex('0f2abd')
Parameters:
{String} hex
hexadecimal string to final update

<static> KJUR.crypto.MessageDigest.digestString(str)
performs final update on the digest using string, then completes the digest computation
md.digestString('aaa')
Parameters:
{String} str
string to final update

<static> KJUR.crypto.MessageDigest.setAlgAndProvider(alg, prov)
set hash algorithm and provider
// for SHA1
md.setAlgAndProvider('sha1', 'cryptojs');
// for RIPEMD160
md.setAlgAndProvider('ripemd160', 'cryptojs');
Parameters:
{String} alg
hash algorithm name
{String} prov
provider name

<static> KJUR.crypto.MessageDigest.updateHex(hex)
update digest by specified hexadecimal string
md.updateHex('0afe36');
Parameters:
{String} hex
hexadecimal string to update

<static> KJUR.crypto.MessageDigest.updateString(str)
update digest by specified string
md.updateString('New York');
Parameters:
{String} str
string to update

© 2012 Kenji Urushima, All rights reserved
Documentation generated by JsDoc Toolkit 2.4.0