-
Notifications
You must be signed in to change notification settings - Fork 15
/
Encrypted_Chat.xml
116 lines (85 loc) · 2.7 KB
/
Encrypted_Chat.xml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Encrypted_Chat"
author="Nick Gammon"
id="af3df750c88cf6defc48799a"
language="Lua"
purpose="Encrypt chat sessions"
date_written="2004-12-10 09:25"
date_modified="2004-12-10 11:50"
requires="3.58"
version="1.0"
>
<description trim="y">
Converts chat sessions to encrypted for the users and keys nominated in the plugin.
</description>
</plugin>
<!-- Script -->
<script>
<![CDATA[
-- amend list of accepted users here (case sensitive)
-- for each user you specify the key you use to exchange messages
keys =
{
Nick = "swordfish",
Peter = "tunafish",
}
-- routine to compress, encrypt and encode a string
function compress_encrypt_encode (s, k)
return utils.base64encode (aes.encrypt (utils.compress (s), k))
end -- compress_encrypt_encode
-- routine to decode, decrypt, and decompress a string
function decode_decrypt_uncompress (s, k)
return utils.decompress (aes.decrypt (utils.base64decode (s), k))
end -- decode_decrypt_uncompress
function OnPluginInstall ()
if not loadlib then
error ("loadlib not available - " ..
"please enable in global preferences")
end -- no loadlib
-- install AES encryption library
if not aes then -- if not installed
f, e = loadlib ("aeslib.dll", "luaopen_aes")
if e then
error ("Could not install Encrypted Chat plugin " ..
"(loading aeslib.dll): " .. e)
end -- if
f () -- install it
end -- if not installed already
Note "Encrypted Chat installed"
end -- function OnPluginInstall
-- decrypt incoming messages
function OnPluginChatMessage (id, message, text)
user = GetChatInfo (id, 2) -- find who they are
if message >= 204 and message <= 206 then
key = keys [user]
if key then
status, result = pcall (decode_decrypt_uncompress, text, key)
if status then
ChatNote (message - 200, result)
else
ColourNote ("white", "red", "Cannot decrypt message from " .. user)
end -- bad result
return false -- we have handled it
end -- one of our known users
end -- if special message
return true -- normal processing
end -- function OnPluginChatMessage
-- encrypt outgoing messages
function OnPluginChatMessageOut (id, message, text)
user = GetChatInfo (id, 2) -- find who they are
if message >= 4 and message <= 6 then
key = keys [user]
if key then
ChatMessage (id, message + 200,
compress_encrypt_encode (text, key))
return false -- we have handled it
end -- one of our known users
end -- if message for everybody/personal/group
return true -- normal processing
end -- function
]]>
</script>
</muclient>