[listener] use a SHA-1 sum for the nick so no user info is shared
This commit is contained in:
parent
11589748c4
commit
de69954bc0
|
@ -19,6 +19,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace SparkleLib {
|
namespace SparkleLib {
|
||||||
|
|
||||||
|
@ -36,26 +37,23 @@ namespace SparkleLib {
|
||||||
public readonly string Nick;
|
public readonly string Nick;
|
||||||
|
|
||||||
|
|
||||||
public SparkleListener (string server, string channel, string nick)
|
public SparkleListener (string server, string folder_name, string user_email)
|
||||||
{
|
{
|
||||||
|
|
||||||
Server = server;
|
Server = server;
|
||||||
Channel = channel;
|
//Channel = GetSHA1 (folder_name);
|
||||||
Nick = nick;
|
Channel = folder_name;
|
||||||
|
|
||||||
if (!Nick.Equals (""))
|
if (!user_email.Equals ("") && user_email != null)
|
||||||
Nick = nick.Replace ("@", "_at_").Replace (".", "_dot_");
|
Nick = GetSHA1 (user_email + "sparkles");
|
||||||
else
|
else
|
||||||
Nick = "anonymous";
|
Nick = GetSHA1 (DateTime.Now.ToString () + "sparkles");
|
||||||
|
|
||||||
// Keep the nick short
|
Nick = "s" + Nick.Substring (0, 7);
|
||||||
if (Nick.Length > 9)
|
|
||||||
Nick = Nick.Substring (0, 9);
|
|
||||||
|
|
||||||
// Channel = "#sparkletest";
|
// TODO: remove
|
||||||
// Server = "irc.gnome.org";
|
Channel = "#sparkletest";
|
||||||
Channel = channel;
|
Server = "irc.gnome.org";
|
||||||
Server = server;
|
|
||||||
|
|
||||||
Client = new IrcClient () {
|
Client = new IrcClient () {
|
||||||
PingTimeout = 120,
|
PingTimeout = 120,
|
||||||
|
@ -114,6 +112,16 @@ namespace SparkleLib {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Creates an SHA-1 hash of input
|
||||||
|
public static string GetSHA1 (string s)
|
||||||
|
{
|
||||||
|
SHA1 sha1 = new SHA1CryptoServiceProvider ();
|
||||||
|
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
|
||||||
|
Byte[] encoded_bytes = sha1.ComputeHash (bytes);
|
||||||
|
return BitConverter.ToString (encoded_bytes).ToLower ().Replace ("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue