Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
87 lines (69 loc) · 2.33 KB

File metadata and controls

87 lines (69 loc) · 2.33 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<head xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<h1>AES256 Encryption Demo for JavaScript</h1>
<style>
#chat_input {
margin: 10px;
width: 90%;
}
div.scroll {
margin: 10px;
padding: 10px;
height: 200px;
width: 800px;
overflow: auto;
border: 1px solid #666;
background: rgb(232,232,232);
padding: 8px;
}
</style>
<div class='scroll' id='chat_box'></div>
<form id="chat_form">
<input type="text" id='chat_input'/>
<input type="submit" value='Send Encrypted Message' id='send'/>
</form>
<button onclick='$("#chat_box").html("")'>Clear All</button>
<script src="../pubnub.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>(function(){
// Encryption Key
// For the optimal way to deliver encryption keys to your PubNub JavaScript app
// Checkout http://blog.pubnub.com/wp-content/uploads/2012/07/PubNubACLForPublishAndSubscribeRealTimeSystems-6.png
var cipher_key = "enigma";
// Create Secure Connection
var secure_pubnub = PUBNUB.secure({
publish_key : "demo",
subscribe_key : "demo",
cipher_key : cipher_key
});
// Secure Connection
secure_pubnub.subscribe({
channel : "hello_world",
callback : display_output
});
// Send Message on Submit
$('#chat_form').submit(function (e) {
secure_pubnub.publish({
channel: "hello_world",
message: $("#chat_input").val(),
callback: function (info) {
// Clear Successfully Sent Message
$("#chat_input").val("");
}
});
e.preventDefault();
return false;
});
function display_output(message){
time = new Date;
h = time.getHours();
m = time.getMinutes();
s = time.getSeconds();
ms = time.getMilliseconds();
formatted_time = "<span style='color:blue;'>" + h + ":" + m + ":" + s + ":" + ms + "</span>";
$('#chat_box').append("Received at " + formatted_time + "<br/>" + message + "</p>");
$("#chat_box").scrollTop($("#chat_box")[0].scrollHeight);
}
})();
</script>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.