[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.Text;
|
||||
using System.Threading;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SparkleLib {
|
||||
|
||||
|
@ -36,26 +37,23 @@ namespace SparkleLib {
|
|||
public readonly string Nick;
|
||||
|
||||
|
||||
public SparkleListener (string server, string channel, string nick)
|
||||
public SparkleListener (string server, string folder_name, string user_email)
|
||||
{
|
||||
|
||||
Server = server;
|
||||
Channel = channel;
|
||||
Nick = nick;
|
||||
//Channel = GetSHA1 (folder_name);
|
||||
Channel = folder_name;
|
||||
|
||||
if (!Nick.Equals (""))
|
||||
Nick = nick.Replace ("@", "_at_").Replace (".", "_dot_");
|
||||
if (!user_email.Equals ("") && user_email != null)
|
||||
Nick = GetSHA1 (user_email + "sparkles");
|
||||
else
|
||||
Nick = "anonymous";
|
||||
Nick = GetSHA1 (DateTime.Now.ToString () + "sparkles");
|
||||
|
||||
// Keep the nick short
|
||||
if (Nick.Length > 9)
|
||||
Nick = Nick.Substring (0, 9);
|
||||
Nick = "s" + Nick.Substring (0, 7);
|
||||
|
||||
// Channel = "#sparkletest";
|
||||
// Server = "irc.gnome.org";
|
||||
Channel = channel;
|
||||
Server = server;
|
||||
// TODO: remove
|
||||
Channel = "#sparkletest";
|
||||
Server = "irc.gnome.org";
|
||||
|
||||
Client = new IrcClient () {
|
||||
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