本文整理汇总了C#中System.Numerics.BigInteger.Select方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.Select方法的具体用法?C# BigInteger.Select怎么用?C# BigInteger.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Numerics.BigInteger
的用法示例。
在下文中一共展示了BigInteger.Select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: encryptFile
private void encryptFile(object sender, RoutedEventArgs e)
{
var bytes = File.ReadAllBytes(filePathOpen.Text);
var open_key = File.ReadAllLines(SenderPath + @"\open_key.txt");
var D = new BigInteger(open_key[0].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
var N = new BigInteger(open_key[1].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
var cryptArr = new BigInteger[(bytes.Length / (N.ToByteArray().Length - 1) + 1)];
for (int i = 0, k = 0; i < bytes.Length; i = i)
{
var data = bytes.Skip(i).Take(N.ToByteArray().Length - 1).ToArray();
cryptArr[k++] = RSAEx.EnCrypt(new BigInteger(data), D, N);
i += data.Length;
}
File.WriteAllLines(filePathEncrypt.Text, cryptArr.Select(intg => string.Join(" ", intg.ToByteArray().Select(a => a.ToString("X")))));
MessageBox.Show("Шифрование завершено");
}
示例2: DecryptVector
public static int[] DecryptVector(BigInteger[] vector, PrivateKey privateKey)
{
return vector.Select(bi => Decrypt(bi, privateKey)).ToArray();
}
示例3: Vote
public static void Vote(string host, int port, CookieCollection cookieCollection, Guid electionId, BigInteger[] encryptedVector)
{
var request = CreateRequest(string.Format("http://{0}:{1}/vote", host, port), WebRequestMethods.Http.Post, null, cookieCollection);
var data = Encoding.UTF8.GetBytes(string.Format("electionId={0}&vote={1}", HttpUtility.UrlEncode(electionId.ToString()), HttpUtility.UrlEncode(encryptedVector.Select(integer => integer.ToString()).ToArray().ToJsonString())));
using(var requestStream = request.GetRequestStream())
requestStream.Write(data, 0, data.Length);
using((HttpWebResponse)request.GetResponse()) { }
}
示例4: EncryptPass
private void EncryptPass(object sender, RoutedEventArgs e)
{
var bytes = File.ReadAllBytes(pathPassTB.Text);
var open_key = File.ReadAllLines(SenderPath + @"\open_key.txt");
var D = new BigInteger(open_key[0].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
var N = new BigInteger(open_key[1].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
var cryptArr = new BigInteger[bytes.Length / N.ToByteArray().Length + 1];
for (int i = 0, k = 0; i < bytes.Length; i = i)
{
var data = bytes.Skip(i).Take(N.ToByteArray().Length).ToArray();
cryptArr[k++] = RSAEx.EnCrypt(new BigInteger(data), D, N);
i += data.Length;
}
File.WriteAllLines(RecipientPath + @"\pass.cod", cryptArr.Select(intg => string.Join(" ", intg.ToByteArray().Select(a => a.ToString("X")))));
decryptPassGrid.Visibility = Visibility.Visible;
}
示例5: VoteAsync
public static async Task VoteAsync(string host, int port, CookieCollection cookieCollection, Guid electionId, BigInteger[] encryptedVector)
{
var data = Encoding.UTF8.GetBytes(string.Format("electionId={0}&vote={1}", HttpUtility.UrlEncode(electionId.ToString()), HttpUtility.UrlEncode(encryptedVector.Select(integer => integer.ToString()).ToArray().ToJsonString())));
var uri = new Uri(string.Format("http://{0}:{1}/vote", host, port));
var httpResult = await AsyncHttpClient.DoRequestAsync(uri, WebRequestMethods.Http.Post, null, cookieCollection, data);
if(httpResult.StatusCode != HttpStatusCode.OK)
throw new ServiceException(ExitCode.MUMBLE, string.Format("Failed to process VoteAsync: {0}", httpResult.StatusCode));
}