blob: 8f75ebe575d791d0045ed9b4ff6b390c513fcea3 [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>
Meki Cherkaoui8f173612012-06-06 01:05:40 -07007 <title>NDN Encode/Decode Content Object</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07008
Jeff Thompson38422f42012-11-15 00:20:39 -08009 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070010
11 <script type="text/javascript">
12
13 function encode(){
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070014 var contentname = new Name( document.getElementById('contentname').value );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070015
16 var content = document.getElementById('content').value;
17
18 var signedInfo = new SignedInfo();
Meki Cherkaoui8f173612012-06-06 01:05:40 -070019
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070020 signedInfo.setFields();
21 //var signatureBits = generateSignatureBits(contentname,content,signedInfo);
22
23 //witness is null
24 var signature = new Signature();
25
26
27 var co = new ContentObject(contentname,signedInfo,content,signature);
28
29 co.sign();
30
31
32 var output = encodeToHexContentObject(co);
33
34 document.getElementById('result').innerHTML = output;
35
36 }
37
38 function decode(){
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070039 var input = document.getElementById('result').innerHTML;
40
Meki Cherkaoui8f173612012-06-06 01:05:40 -070041 input = input.toUpperCase();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070042
43 var co = decodeHexContentObject(input);
44
45 if(LOG>3)console.log('CONTENT OBJECT DECODED');
46 if(LOG>3)console.log(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070047
jeffcc8b3a92012-09-03 15:13:27 -070048 document.getElementById('result').innerHTML = contentObjectToHtml(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070049 }
50
51 </script>
52
53</head>
54<body >
55 <form>
56
57 Please Enter a Content Name:<br />
58
59 <input id="contentname" type="text" name="CONTENTNAME" value="/PARC/abc" />
60
Jeff Thompson12b029d2012-08-26 11:51:27 -070061 <br />Please Enter the Content:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070062
63 <textarea id="content" cols="40" rows="5" name="CONTENT" value="SUCCESS" >SUCCESS!</textarea>
64
65 </form>
66 <button onclick="encode()">Encode</button>
67 <button onclick="decode()">Decode</button>
68
69
Jeff Thompson12b029d2012-08-26 11:51:27 -070070 <p id="result"></p>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070071
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070072
73</body>
jeffcc8b3a92012-09-03 15:13:27 -070074</html>