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


C# System.Security.Cryptography.RNGCryptoServiceProvider.GetNonZeroBytes方法代码示例

本文整理汇总了C#中System.Security.Cryptography.RNGCryptoServiceProvider.GetNonZeroBytes方法的典型用法代码示例。如果您正苦于以下问题:C# System.Security.Cryptography.RNGCryptoServiceProvider.GetNonZeroBytes方法的具体用法?C# System.Security.Cryptography.RNGCryptoServiceProvider.GetNonZeroBytes怎么用?C# System.Security.Cryptography.RNGCryptoServiceProvider.GetNonZeroBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Cryptography.RNGCryptoServiceProvider的用法示例。


在下文中一共展示了System.Security.Cryptography.RNGCryptoServiceProvider.GetNonZeroBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ZActor

		/// <summary>
		/// You are using ZContext.Current!
		/// </summary>
		public ZActor(ZAction0 action, params object[] args)
			: this(default(string), action, args)
		{
			var rnd0 = new byte[8];
			using (var rng = new System.Security.Cryptography.RNGCryptoServiceProvider()) rng.GetNonZeroBytes(rnd0);
			this.Endpoint = string.Format("inproc://{0}", ZContext.Encoding.GetString(rnd0));
		}
开发者ID:shenxuejin,项目名称:clrzmq4,代码行数:10,代码来源:ZActor.cs

示例2: GetRandomPrime

 public async Task<IHttpActionResult> GetRandomPrime()
 {
     var rnd = new System.Security.Cryptography.RNGCryptoServiceProvider();
     var bytes = new byte[16];
     var result = await Task.Run(() =>
     {
         rnd.GetNonZeroBytes(bytes);
         var res = new BigInteger(bytes);
         while (!res.IsProbablePrime(10))
         {
             rnd.GetNonZeroBytes(bytes);
             res = new BigInteger(bytes);
         }
         return res;
     });
     Debug.WriteLine(result);
     return Json(result.ToString());
 }
开发者ID:pashchuk,项目名称:data-security-labs,代码行数:18,代码来源:NumberController.cs

示例3: GetUniqueKey

 public static string GetUniqueKey(int maxSize)
 {
     char[] chars = new char[62];
     chars =
     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
     byte[] data = new byte[1];
     using (System.Security.Cryptography.RNGCryptoServiceProvider crypto = new System.Security.Cryptography.RNGCryptoServiceProvider())
     {
         crypto.GetNonZeroBytes(data);
         data = new byte[maxSize];
         crypto.GetNonZeroBytes(data);
     }
     StringBuilder result = new StringBuilder(maxSize);
     foreach (byte b in data)
     {
         result.Append(chars[b % (chars.Length)]);
     }
     return result.ToString();
 }
开发者ID:SecuredSigning,项目名称:.NET-Client-SDK,代码行数:19,代码来源:AuthHelper.cs

示例4: StartReporting

        /// <summary>
        /// Начинать слушать порт, на который приходят RTCP пакеты
        /// и слать в ответ свои
        /// </summary>
        public void StartReporting()
        {
            var random = new System.Security.Cryptography.RNGCryptoServiceProvider();

            byte[] randomBytes = new byte[sizeof(UInt32)];
            random.GetNonZeroBytes(randomBytes);

            recieverSSRC = BitConverter.ToUInt32(randomBytes, 0);
            senderReportCount = 0;
            receivedRtpPackets = 0;
            recieverReportCount = 0;
            initTimestamp = 0;

            udpClient.StartReceiving();
        }
开发者ID:Rukhlov,项目名称:TestOnvif,代码行数:19,代码来源:RtcpReporter.cs

示例5: GenerateSalt

        /// <summary>
        /// Gera um SALT.
        /// </summary>
        /// <returns>SALT.</returns>
        private byte[] GenerateSalt()
        {
            System.Security.Cryptography.RNGCryptoServiceProvider v_randomnumbergenerator;
            byte[] v_salt;
            int v_saltlength;

            if (this.v_minsaltlength == this.v_maxsaltlength)
                v_saltlength = this.v_minsaltlength;
            else
                v_saltlength = this.GenerateRandomNumber(this.v_minsaltlength, this.v_maxsaltlength);

            v_salt = new byte[v_saltlength];

            v_randomnumbergenerator = new System.Security.Cryptography.RNGCryptoServiceProvider();
            v_randomnumbergenerator.GetNonZeroBytes(v_salt);

            v_salt[0] = (byte)((v_salt[0] & 0xfc) | (v_saltlength & 0x03));
            v_salt[1] = (byte)((v_salt[1] & 0xf3) | (v_saltlength & 0x0c));
            v_salt[2] = (byte)((v_salt[2] & 0xcf) | (v_saltlength & 0x30));
            v_salt[3] = (byte)((v_salt[3] & 0x3f) | (v_saltlength & 0xc0));

            return v_salt;
        }
开发者ID:lubota,项目名称:spartacus,代码行数:27,代码来源:Spartacus.Utils.Cryptor.cs


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