blob: 092f56f8360455aefa46df0495cc257369808f4e [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 Thompson7ed5ef52012-08-26 11:28:48 -07009 <script type="text/javascript" src="../java_socket_bridge.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070010
Jeff Thompsonc3164722012-09-30 18:35:02 -070011 <script type="text/javascript" src="../util/CCNProtocolDTags.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070012
Jeff Thompsonc3164722012-09-30 18:35:02 -070013 <script type="text/javascript" src="../util/CCNTime.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070014
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070015 <script type="text/javascript" src="../Name.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070016
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070017 <script type="text/javascript" src="../ContentObject.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070018
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070019 <script type="text/javascript" src="../Interest.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070020
Jeff Thompsonc3164722012-09-30 18:35:02 -070021 <script type="text/javascript" src="../Key.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070022
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070023 <script type="text/javascript" src="../PublisherID.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070024
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070025 <script type="text/javascript" src="../PublisherPublicKeyDigest.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070026
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070027 <script type="text/javascript" src="../FaceInstance.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070028
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070029 <script type="text/javascript" src="../ForwardingEntry.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070030
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070031 <script type="text/javascript" src="../encoding/BinaryXMLEncoder.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070032
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070033 <script type="text/javascript" src="../encoding/BinaryXMLDecoder.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070034
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070035 <script type="text/javascript" src="../encoding/DataUtils.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070036
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070037 <script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070038
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070039 <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070040
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070041 <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
42 <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
43 <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
44 <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070045
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070046 <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
47 <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
48 <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
49 <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
50 <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
51 <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070052
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070053 <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.js"></script>
54 <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.js"></script>
55 <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.js"></script>
56 <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070057
58 <script type="text/javascript">
59
60 function encode(){
Jeff Thompsonf3bd3592012-09-29 23:25:30 -070061 var contentname = new Name( document.getElementById('contentname').value );
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070062
63 var content = document.getElementById('content').value;
64
65 var signedInfo = new SignedInfo();
Meki Cherkaoui8f173612012-06-06 01:05:40 -070066
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070067 signedInfo.setFields();
68 //var signatureBits = generateSignatureBits(contentname,content,signedInfo);
69
70 //witness is null
71 var signature = new Signature();
72
73
74 var co = new ContentObject(contentname,signedInfo,content,signature);
75
76 co.sign();
77
78
79 var output = encodeToHexContentObject(co);
80
81 document.getElementById('result').innerHTML = output;
82
83 }
84
85 function decode(){
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070086 var input = document.getElementById('result').innerHTML;
87
Meki Cherkaoui8f173612012-06-06 01:05:40 -070088 input = input.toUpperCase();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070089
90 var co = decodeHexContentObject(input);
91
92 if(LOG>3)console.log('CONTENT OBJECT DECODED');
93 if(LOG>3)console.log(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070094
jeffcc8b3a92012-09-03 15:13:27 -070095 document.getElementById('result').innerHTML = contentObjectToHtml(co);
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070096 }
97
98 </script>
99
100</head>
101<body >
102 <form>
103
104 Please Enter a Content Name:<br />
105
106 <input id="contentname" type="text" name="CONTENTNAME" value="/PARC/abc" />
107
Jeff Thompson12b029d2012-08-26 11:51:27 -0700108 <br />Please Enter the Content:<br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700109
110 <textarea id="content" cols="40" rows="5" name="CONTENT" value="SUCCESS" >SUCCESS!</textarea>
111
112 </form>
113 <button onclick="encode()">Encode</button>
114 <button onclick="decode()">Decode</button>
115
116
Jeff Thompson12b029d2012-08-26 11:51:27 -0700117 <p id="result"></p>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700118
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700119
120</body>
jeffcc8b3a92012-09-03 15:13:27 -0700121</html>