Class Index | File Index

Classes


Namespace Pot.Crypt


Defined in: <pot.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Crypt and Hash utilities.
Method Summary
Method Attributes Method Name and Description
<static>  
Pot.Crypt.Arc4((key))
ARC4 symmetric cipher encryption/decryption.
<static>  
Pot.Crypt.crc32(data)
Calculate the 32-bit CRC (cyclic redundancy checksum) checksum.
<static>  
Pot.Crypt.hashCode(data)
String hash function similar to java.lang.String.hashCode().
<static>  
Pot.Crypt.md5(data)
Calculate the MD5 hash of a string.
<static>  
Pot.Crypt.sha1(data)
Calculate the SHA1 hash of a string.
Namespace Detail
Pot.Crypt
Crypt and Hash utilities.
Method Detail
<static> {Function} Pot.Crypt.Arc4((key))
ARC4 symmetric cipher encryption/decryption. Original algorithm: {@link http://www.mozilla.org/projects/security/pki/nss/ draft-kaukonen-cipher-arcfour-03.txt}
  var arc4 = new Pot.Crypt.Arc4();
  arc4.setKey('hoge');
  var cipherText = arc4.encrypt('Hello World!');
  debug('cipherText = ' + cipherText);
  // @results 'cipherText = (...cipherText)'
  var origText = arc4.decrypt(cipherText);
  debug('origText = ' + origText);
  // @results 'origText = Hello World!'
Parameters:
{String} (key)
Secret key for encryption.
Returns:
{Object} The instance of Arc4 object.

<static> {Function} Pot.Crypt.crc32(data)
Calculate the 32-bit CRC (cyclic redundancy checksum) checksum.
  debug(crc32('abc123'));
  // @results  -821904548
Parameters:
{String|Array} data
Data.
Returns:
{Number} CRC checksum.

<static> {Function} Pot.Crypt.hashCode(data)
String hash function similar to java.lang.String.hashCode(). The hash code for a string is computed as s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], where s[i] is the ith character of the string and n is the length of the string. We mod the result to make it between 0 (inclusive) and 2^32 (exclusive).
  Pot.debug( Pot.hashCode('abc') ); // 96354
  Pot.debug( Pot.hashCode([0x61, 0x62, 0x63]) ); // 96354
Parameters:
{String|Array|*} data
A target data.
Returns:
{Number} Hash value for `string`, between 0 (inclusive) and 2^32 (exclusive). The empty string returns 0.

<static> {Function} Pot.Crypt.md5(data)
Calculate the MD5 hash of a string. RFC 1321 - The MD5 Message-Digest Algorithm
  debug(md5('apple'));
  // @results '1f3870be274f6c49b3e31a0c6728957f'
Parameters:
{String|Array} data
The target data.
Returns:
{String} The result string.
See:
http://www.faqs.org/rfcs/rfc1321

<static> {Function} Pot.Crypt.sha1(data)
Calculate the SHA1 hash of a string. RFC 3174 - US Secure Hash Algorithm 1 (SHA1)
  debug(sha1('apple'));
  // @results 'd0be2dc421be4fcd0172e5afceea3970e2f3d940'
Parameters:
{String|Array} data
The input data.
Returns:
{String} Returns the sha1 hash as a string.
See:
http://www.faqs.org/rfcs/rfc3174

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 21 2012 19:32:22 GMT+0900 (JST)