blob: eb55741e71e1dea6d73cfcf6240357c6a70b2181 [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">
Jeff Burke92dd8e42012-12-08 11:40:31 -08004<!--
5 See COPYING for copyright and distribution information.
6-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07007<html xmlns = "http://www.w3.org/1999/xhtml">
8
9<head>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070010 <title>NDN Encode/Decode Content Object</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070011
Jeff Thompson38422f42012-11-15 00:20:39 -080012 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070013
14 <script type="text/javascript">
15
16 function encode(){
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070017 var contentname = new Name( document.getElementById('contentname').value );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070018
19 var content = document.getElementById('content').value;
20
21 var signedInfo = new SignedInfo();
Meki Cherkaoui8f173612012-06-06 01:05:40 -070022
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070023 signedInfo.setFields();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070024
25 //witness is null
26 var signature = new Signature();
27
28
29 var co = new ContentObject(contentname,signedInfo,content,signature);
30
31 co.sign();
32
33
34 var output = encodeToHexContentObject(co);
35
36 document.getElementById('result').innerHTML = output;
37
38 }
39
40 function decode(){
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070041 var input = document.getElementById('result').innerHTML;
42
Meki Cherkaoui8f173612012-06-06 01:05:40 -070043 input = input.toUpperCase();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070044
45 var co = decodeHexContentObject(input);
46
47 if(LOG>3)console.log('CONTENT OBJECT DECODED');
48 if(LOG>3)console.log(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070049
jeffcc8b3a92012-09-03 15:13:27 -070050 document.getElementById('result').innerHTML = contentObjectToHtml(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070051 }
52
53 </script>
54
55</head>
56<body >
57 <form>
58
59 Please Enter a Content Name:<br />
60
Jeff Thompsonbd829262012-11-30 22:28:37 -080061 <input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070062
Jeff Thompson12b029d2012-08-26 11:51:27 -070063 <br />Please Enter the Content:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070064
65 <textarea id="content" cols="40" rows="5" name="CONTENT" value="SUCCESS" >SUCCESS!</textarea>
66
67 </form>
68 <button onclick="encode()">Encode</button>
69 <button onclick="decode()">Decode</button>
70
71
Jeff Thompson12b029d2012-08-26 11:51:27 -070072 <p id="result"></p>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070073
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070074
75</body>
jeffcc8b3a92012-09-03 15:13:27 -070076</html>