本文整理匯總了C#中System.Security.Cryptography.MD5CryptoServiceProvider.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# MD5CryptoServiceProvider.Select方法的具體用法?C# MD5CryptoServiceProvider.Select怎麽用?C# MD5CryptoServiceProvider.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.Cryptography.MD5CryptoServiceProvider
的用法示例。
在下文中一共展示了MD5CryptoServiceProvider.Select方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Gravatar
public object Gravatar(string email)
{
byte[] rawHash = new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(email.ToLower()));
string hash = rawHash.Select(b => b.ToString("x2")).Aggregate((c, n) => c += n);
return Resource(
System.Net.WebRequest.Create("http://www.gravatar.com/avatar/" + hash).GetResponse().GetResponseStream(),
"image/jpg");
}
示例2: Generate
public static int Generate(UdpTestParameters parms)
{
var hostName = System.Environment.MachineName + "." +
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
"SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters").GetValue("Domain", "").ToString();
IPAddress broadcast;
if (!IPAddress.TryParse(parms.Host, out broadcast))
broadcast = Dns.GetHostEntry(parms.Host).AddressList[0];
Socket s = new Socket(broadcast.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
LogManager.GetCurrentClassLogger().Info("Start UDP Generation");
for (int i = 0; i < parms.NumMessages; i++)
{
JObject o = new JObject
{
{"Application", "udp-generator"},
{"Executable", "VP.Common.SvcFrm.Services.Host, Version=29.7.0.0, Culture=neutral, PublicKeyToken=null"},
{"RenderedMessage", "Responding to RequestSchedule message from 10.1.230.36 with Ack because: PRJ byte array is null."},
{"Team", "Manufacturing Software"},
{"RecordNumber", i},
{"Host", hostName},
{"UtcTimestamp", DateTime.UtcNow.ToString("o")},
{"Type", "VP.Fulfillment.Direct.Initialization.LogWrapper"},
{"Message", "Testgenerator udp message " + DateTime.UtcNow.ToString("o")},
{"Index", "logstash"}
};
string hashedString = "";
foreach(var key in o)
{
hashedString += key.ToString();
}
var source = ASCIIEncoding.ASCII.GetBytes(hashedString);
var md5 = new MD5CryptoServiceProvider().ComputeHash(source);
var hash = string.Concat(md5.Select(x => x.ToString("X2")));
o["md5"] = hash;
byte[] sendbuf = Encoding.UTF8.GetBytes(o.ToString(Formatting.None));
IPEndPoint ep = new IPEndPoint(broadcast, parms.Port);
s.SendTo(sendbuf, ep);
if (i % 1000 == 0)
LogManager.GetCurrentClassLogger().Info("Sent {0} of {1} messages", i, parms.NumMessages);
Thread.Sleep(parms.SleepTimeMilliseconds);
}
LogManager.GetCurrentClassLogger().Info("Finished UDP Generation");
return parms.NumMessages;
}