forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaes.html
More file actions
63 lines (49 loc) · 1.48 KB
/
aes.html
File metadata and controls
63 lines (49 loc) · 1.48 KB
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
<!--This example uses raw sources below-->
<script src=../../../web/pubnub.js></script>
<script src=../../../core/crypto/gibberish-aes.js></script>
<script src=../../../core/crypto/encrypt-pubnub.js></script>
<!--Production should use:
<script src=https://pubnub.a.ssl.fastly.net/pubnub-3.4.x.min.js></script>
<script src=https://pubnub.a.ssl.fastly.net/pubnub-crypto-3.4.x.min.js></script>
See:
https://github.com/pubnub/javascript/blob/master/README.md#aes-cryptography
For latest script reference
-->
<script>(function(){
var secure_pubnub = PUBNUB.secure({
publish_key : 'demo',
subscribe_key : 'demo',
ssl : true,
cipher_key : 'enigma'
});
secure_pubnub.subscribe({
channel : 'my_channel',
connect : send_hello,
message : receive_hello
});
function receive_hello(hello) {
console.log(hello);
}
function send_hello() {
console.log("Sent!");
secure_pubnub.publish({
channel : 'my_channel',
message : 'hello!',
callback : unsubscribe_me
});
}
function unsubscribe_me() {
secure_pubnub.unsubscribe({
channel: 'my_channel'
});
}
function get_encrypted_history() {
secure_pubnub.history({
channel: channel,
limit: 15,
callback: function(notifications) {
console.log(notifications);
}
});
}
})();</script>