| <?xml version = "1.0" encoding="utf-8" ?> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
| "DTD/xhtml1-strict.dtd"> | |
| <!-- | |
| See COPYING for copyright and distribution information. | |
| --> | |
| <html xmlns = "http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title>Test SHA-256</title> | |
| <script type="text/javascript" src="../build/ndn-js.js"></script> | |
| <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/sha256.js"></script> | |
| <script type="text/javascript"> | |
| function hash(){ | |
| var input = document.getElementById('contentname').value; | |
| var output = "from string- " + hex_sha256(input) + "<br/>"; | |
| var sha256 = new Sha256(); | |
| var data = DataUtils.toNumbersFromString(input); | |
| // Call update multiple times in small chunks to test the buffering. | |
| var chunkSize = 3; | |
| var nCalls = Math.floor(data / chunkSize); | |
| for (var i = 0; i < nCalls; ++i) | |
| sha256.update(data.subarray(i * chunkSize, chunkSize)); | |
| sha256.update(data.subarray(i * nCalls, data.length)); | |
| output += "from bytes-- " + DataUtils.toHex(sha256.finalize()) + "<br/>"; | |
| output += "reference---- " + CryptoJS.SHA256(input); | |
| document.getElementById('result').innerHTML = output; | |
| } | |
| </script> | |
| </head> | |
| <body > | |
| <form> | |
| Please Enter Text to Hash:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" /> <br /> | |
| </form> | |
| <button onclick="hash()">Hash</button> | |
| <p id="result"></p> | |
| </body> | |
| </html> |