Skip to content

Instantly share code, notes, and snippets.

@locks
Created January 12, 2010 13:46
Show Gist options
  • Save locks/275206 to your computer and use it in GitHub Desktop.
Save locks/275206 to your computer and use it in GitHub Desktop.
dotNET toolbox
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