Created
January 12, 2010 13:46
-
-
Save locks/275206 to your computer and use it in GitHub Desktop.
dotNET toolbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography; | |
using System.Text; | |
using System.Net.Mail; | |
class Toolbox { | |
public static String GenerateToken() { | |
return Guid.NewGuid().ToString(); | |
} | |
private static string GenerateSaltedHash(string value, string salt) | |
{ | |
byte[] data = System.Text.Encoding.ASCII.GetBytes(salt + value); | |
data = System.Security.Cryptography.SHA512.Create().ComputeHash(data); | |
return Convert.ToBase64String(data); | |
} | |
private static void SendEmail(string user_mail, string subject, string body) | |
{ | |
MailMessage email = new MailMessage(); | |
email.From = new MailAddress("admin@minimo10.com"); | |
email.To.Add(user_mail); | |
email.Subject = subject; | |
email.Body = body; | |
//new SmtpClient("localhost").Send(email); | |
new SmtpClient("localhost").Send( | |
"admin@minimo10.com", | |
user_mail, | |
subject, | |
body | |
); | |
} | |
public static void Main() | |
{ | |
Console.WriteLine(GenerateSaltedHash("locks", "salt").ToString().Length); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment