blob: 5980dac1f2188f36872f5f2f9bea2a0308c6355f [file] [log] [blame]
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
4<html xmlns = "http://www.w3.org/1999/xhtml">
5
6<head>
Jeff Thompson8ecc0762012-08-18 17:09:11 -07007 <title>Test SHA-256</title>
Jeff Thompson38422f42012-11-15 00:20:39 -08008
9 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070010
Meki Cherkaoui8f173612012-06-06 01:05:40 -070011 <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha256.js"></script>
12
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070013 <script type="text/javascript">
Jeff Thompsonf9a0bc22012-12-02 22:16:16 -080014 function hash(){
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070015 var input = document.getElementById('contentname').value;
16
Jeff Thompson9b288b32012-12-01 14:25:05 -080017 var output = "from string- " + hex_sha256(input) + "<br/>";
Jeff Thompsonf9a0bc22012-12-02 22:16:16 -080018
19 var sha256 = new Sha256();
20 var data = DataUtils.toNumbersFromString(input);
21 // Call update multiple times in small chunks to test the buffering.
22 var chunkSize = 3;
23 var nCalls = Math.floor(data / chunkSize);
24 for (var i = 0; i < nCalls; ++i)
25 sha256.update(data.subarray(i * chunkSize, chunkSize));
26 sha256.update(data.subarray(i * nCalls, data.length));
27 output += "from bytes-- " + DataUtils.toHex(sha256.finalize()) + "<br/>";
28
Jeff Thompson9b288b32012-12-01 14:25:05 -080029 output += "reference---- " + CryptoJS.SHA256(input);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070030
31 document.getElementById('result').innerHTML = output;
Jeff Thompson9b288b32012-12-01 14:25:05 -080032 }
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070033 </script>
34
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070035</head>
36<body >
37 <form>
Jeff Thompsonbd829262012-11-30 22:28:37 -080038 Please Enter Text to Hash:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" /> <br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070039 </form>
40 <button onclick="hash()">Hash</button>
41
42 <p id="result"></p>
43
44</body>
jeff6c388572012-09-02 15:30:17 -070045</html>