Ejemplo n.º 1
0
        /// <summary>
        /// Is Hit
        /// </summary>
        /// <param name="percent">percent: (0 - 100)</param>
        /// <param name="rand">rand</param>
        /// <returns></returns>
        public static bool IsHit(int percent, ref int rand)
        {
            if (percent < 0)
            {
                percent = 0;
                return(false);
            }

            if (percent > 100)
            {
                percent = 100;
                return(true);
            }

            int val = RandTool.CreateRandValWithMinMax(0, Int32.MaxValue);

            rand = val;

            if (val % percent == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Encrypt
        /// </summary>
        /// <param name="clearText"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string Encrypt(string clearText, string key)
        {
            string cipherText = "";

            if (clearText.Length >= 6)
            {
                string md5Str     = Md5EncryptionTool.Encrypt(key);
                var    indexStart = DateTime.Now.Day;

                string cipherText1 = "";
                for (int i = 0; i < clearText.Length; i++)
                {
                    int  index   = (indexStart + i) >= 32 ? (indexStart + i - 32) : (indexStart + i);
                    byte ch      = (byte)clearText[i];
                    byte ch1     = (byte)md5Str[index];
                    byte newByte = (byte)(ch + ch1);
                    cipherText1 += (char)newByte;
                }

                string prefix = "";
                int    ran    = RandTool.CreateRandValWithMinMax(6, 10);
                for (int i = 0; i < ran; i++)
                {
                    int ran1 = RandTool.CreateRandValWithMinMax(0, 31);
                    prefix += md5Str[ran1];
                }

                string suffix = ran.ToString();

                cipherText = string.Format("{0}{1}{2}", prefix, cipherText1, suffix);
            }
            else
            {
                cipherText = "";
            }

            return(cipherText);
        }