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


C# BigInteger.GetBytes方法代码示例

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


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

示例1: GetE

		//    myKeyAgree=KeyAgreement.getInstance("DiffieHellman");
		/// <exception cref="System.Exception"></exception>
		public virtual byte[] GetE()
		{
			if (e == null)
			{
				DHParameterSpec dhSkipParamSpec = new DHParameterSpec(p, g);
				myKpairGen.Initialize(dhSkipParamSpec);
				Sharpen.KeyPair myKpair = myKpairGen.GenerateKeyPair();
				myKeyAgree.Init(myKpair.GetPrivate());
				//    BigInteger x=((javax.crypto.interfaces.DHPrivateKey)(myKpair.getPrivate())).getX();
				e = ((DHPublicKey)(myKpair.GetPublic())).GetY();
				e_array = e.GetBytes();
			}
			return e_array;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:16,代码来源:DH.cs

示例2: GetCounterHexValue

        public static byte[] GetCounterHexValue(BigInteger counter)
        {
            byte[] counterBytes = counter.GetBytes();
            counterBytes = PppConvert.SwapBits(counterBytes);
            int padNeeded = 16 - counterBytes.Length;
            List<byte> padedBytes;

            if (counterBytes.Length != 16)
            {
                padedBytes = new List<byte>(16);
                padedBytes.AddRange(counterBytes);
                padedBytes.AddRange(new byte[padNeeded]);
            }
            else
            {
                padedBytes = new List<byte>(counterBytes);
            }
            return padedBytes.ToArray();
        }
开发者ID:ErebusBat,项目名称:pppNET,代码行数:19,代码来源:pppHelper.cs

示例3: GetK

		/// <exception cref="System.Exception"></exception>
		public virtual byte[] GetK()
		{
			if (K == null)
			{
				KeyFactory myKeyFac = KeyFactory.GetInstance("DH");
				DHPublicKeySpec keySpec = new DHPublicKeySpec(f, p, g);
				PublicKey yourPubKey = myKeyFac.GeneratePublic(keySpec);
				myKeyAgree.DoPhase(yourPubKey, true);
				byte[] mySharedSecret = myKeyAgree.GenerateSecret();
				K = new BigInteger(mySharedSecret);
				K_array = K.GetBytes();
				//System.err.println("K.signum(): "+K.signum()+
				//		   " "+Integer.toHexString(mySharedSecret[0]&0xff)+
				//		   " "+Integer.toHexString(K_array[0]&0xff));
				K_array = mySharedSecret;
			}
			return K_array;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:19,代码来源:DH.cs

示例4: BigIntToMpi

 public static byte[] BigIntToMpi(BigInteger bint)
 {
     var ibytes = bint.GetBytes();//.Reverse().ToArray();
     var shift = 0;// ibytes[0] == 0 ? 1 : 0;
     var length = ibytes.Length - shift;
     var bytes = new byte[length + 2];
     ushort ulength = Convert.ToUInt16(length * 8);
     bytes[0] = (byte)(ulength >> 8);
     bytes[1] = (byte)(ulength & 0xff);
     Array.Copy(ibytes, shift, bytes, 2, length);
     return bytes;
 }
开发者ID:exaphaser,项目名称:megadesktop,代码行数:12,代码来源:Converter.cs

示例5: GetPaddedValue

		private byte[] GetPaddedValue (BigInteger value, int length)
		{
			byte[] result = value.GetBytes ();
			if (result.Length >= length)
				return result;

			// left-pad 0x00 value on the result (same integer, correct length)
			byte[] padded = new byte[length];
			Buffer.BlockCopy (result, 0, padded, (length - result.Length), result.Length);
			// temporary result may contain decrypted (plaintext) data, clear it
			Array.Clear (result, 0, result.Length);
			return padded;
		}
开发者ID:Jakosa,项目名称:MonoLibraries,代码行数:13,代码来源:RSAManaged.cs

示例6: EncodeBigInteger

            private static System.Numerics.BigInteger EncodeBigInteger(BigInteger v)
            {
                var bytes = v.GetBytes();

                Array.Reverse(bytes);

                if ((bytes[bytes.Length - 1] & 128) != 0)
                    Array.Resize(ref bytes, bytes.Length + 1);

                return new System.Numerics.BigInteger(bytes);
            }
开发者ID:cdrnet,项目名称:ngit,代码行数:11,代码来源:BigInteger.cs

示例7: RSAExptmod

        //for that it s strange because it s a quite different of DecryptValue and encryptvalue
        //but maybe it s the same thanks to math ;)
        //so need to do some math to check...
        public byte[] RSAExptmod(byte[] PacketIn, eRSAKeyFormat format)
        {
            BigInteger tmp, tmpa, tmpb;

            //todo more check key generate format packet in and out null...

            tmp = new BigInteger(PacketIn);

            /* are we using the private exponent */
            if (format == eRSAKeyFormat.PK_PRIVATE )
            {
                // m1 = c^dp mod p
                tmpa = tmp.ModPow (dp, p);
                tmpb = tmp.ModPow (dq, q);
                tmp = (tmpa * qP + tmpb*pQ).ModPow (0, n);
            }
            else
            {
                tmp = tmp.ModPow (e, n);
            }

            /* convert it */
            return tmp.GetBytes();
        }
开发者ID:Dawn-of-Light,项目名称:TomCryptLibNET,代码行数:27,代码来源:DAOCCryptManager.cs


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