当前位置: 首页>>代码示例>>C#>>正文


C# BigInteger.Select方法代码示例

本文整理汇总了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("Шифрование завершено");
 }
开发者ID:klyuchnikov,项目名称:Miszki,代码行数:16,代码来源:MainWindow.xaml.cs

示例2: DecryptVector

 public static int[] DecryptVector(BigInteger[] vector, PrivateKey privateKey)
 {
     return vector.Select(bi => Decrypt(bi, privateKey)).ToArray();
 }
开发者ID:HackerDom,项目名称:ructfe-2015,代码行数:4,代码来源:HomoCrypto.cs

示例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()) { }
		}
开发者ID:HackerDom,项目名称:ructfe-2015,代码行数:10,代码来源:ElectroClient.cs

示例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;
 }
开发者ID:klyuchnikov,项目名称:Miszki,代码行数:16,代码来源:MainWindow.xaml.cs

示例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));
		}
开发者ID:HackerDom,项目名称:ructfe-2015,代码行数:9,代码来源:ElectroClient.cs


注:本文中的System.Numerics.BigInteger.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。