<?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>NDN Encode/Decode Content Object</title> | |
<script type="text/javascript" src="../build/ndn-js.js"></script> | |
<script type="text/javascript"> | |
function encode(){ | |
var contentname = new Name( document.getElementById('contentname').value ); | |
var content = document.getElementById('content').value; | |
var signedInfo = new SignedInfo(); | |
signedInfo.setFields(); | |
//witness is null | |
var signature = new Signature(); | |
var co = new ContentObject(contentname,signedInfo,content,signature); | |
co.sign(); | |
var output = encodeToHexContentObject(co); | |
document.getElementById('result').innerHTML = output; | |
} | |
function decode(){ | |
var input = document.getElementById('result').innerHTML; | |
input = input.toUpperCase(); | |
var co = decodeHexContentObject(input); | |
if(LOG>3)console.log('CONTENT OBJECT DECODED'); | |
if(LOG>3)console.log(co); | |
document.getElementById('result').innerHTML = contentObjectToHtml(co); | |
} | |
</script> | |
</head> | |
<body > | |
<form> | |
Please Enter a Content Name:<br /> | |
<input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" /> | |
<br />Please Enter the Content:<br /> | |
<textarea id="content" cols="40" rows="5" name="CONTENT" value="SUCCESS" >SUCCESS!</textarea> | |
</form> | |
<button onclick="encode()">Encode</button> | |
<button onclick="decode()">Decode</button> | |
<p id="result"></p> | |
</body> | |
</html> |