Esempio n. 1
0
        private static string Backward(string s)
        {
            string str3 = "";
            string str2 = s.Substring(0x11, 6);
            int    num  = 0;
            int    num5 = s.Length - 1;

            for (int i = 0; i <= num5; i++)
            {
                int index = "LAPQMZ01NXOWKS29DJEUCB3I8RYFH475V6TG".IndexOf(s[i]);
                if ((i < 0x11) | (i > 0x16))
                {
                    int num4 = "LAPQMZ01NXOWKS29DJEUCB3I8RYFH475V6TG".IndexOf(str2[num]);
                    index -= num4;
                    if (index < 0)
                    {
                        index += 0x24;
                    }
                    num++;
                    if (num > (str2.Length - 1))
                    {
                        num = 0;
                    }
                }
                str3 = str3 + StringType.FromChar("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[index]);
            }
            return(str3);
        }
Esempio n. 2
0
        /// <summary>
        /// 密码解密
        /// </summary>
        /// <param name="inStr">密文</param>
        /// <returns>明文</returns>
        public static string DecryptPwd(string inStr)
        {
            int    num2;
            string str2 = "";
            int    num6 = Strings.Len(Strings.Trim(inStr));
            int    num3 = num6 % 3;
            int    num4 = num6 % 9;
            int    num5 = num6 % 5;

            if ((((double)num6) / 2.0) == Conversion.Int((double)(((double)num6) / 2.0)))
            {
                num2 = num4 + num5;
            }
            else
            {
                num2 = num3 + num5;
            }
            int num7 = num6;

            for (int i = 1; i <= num7; i++)
            {
                str2 = str2 + StringType.FromChar(Strings.Chr(Strings.Asc(Strings.Mid(inStr, (num6 + 1) - i, 1)) + num2));
                if (num2 == (num3 + num5))
                {
                    num2 = num4 + num5;
                }
                else
                {
                    num2 = num3 + num5;
                }
            }
            return(str2 + Strings.Space(Strings.Len(inStr) - num6));
        }
        public string DecryptWord(string DecryptIt, string Weight)
        {
            string str3 = "";

            if (!this.IsValidUser)
            {
                throw new Exception("You can't use it without permission.");
            }

            if (Strings.Len(Strings.Trim(DecryptIt)) == 0)
            {
                return("");
            }
            long num2 = this.ReturnWeight(Weight);

            VBMath.Rnd(-1f);
            if (Strings.Len(Strings.Trim(Weight)) == 0)
            {
                VBMath.Randomize(5.0);
            }
            else
            {
                VBMath.Randomize((double)num2);
            }
            for (long i = 1L; i <= Strings.Len(DecryptIt); i += 1L)
            {
                long num = Strings.Asc(Strings.Mid(DecryptIt, (int)i, 1)) - ((int)Math.Round((double)((100f * VBMath.Rnd()) + 1f)));
                if (num > 0xffL)
                {
                    num -= 0xffL;
                }
                if (num < 1L)
                {
                    num += 0xffL;
                }
                str3 = str3 + StringType.FromChar(Strings.Chr((int)num));
            }
            return(str3);
        }
Esempio n. 4
0
        /// <summary>
        /// 密码加密
        /// </summary>
        /// <param name="inStr">明文</param>
        /// <returns>密文</returns>
        public static string EncryptPwd(string inStr)
        {
            string str2 = "";
            int    num6 = Strings.Len(Strings.Trim(inStr));
            int    num3 = num6 % 3;
            int    num4 = num6 % 9;
            int    num5 = num6 % 5;
            int    num2 = num3 + num5;
            int    num7 = num6;

            for (int i = 1; i <= num7; i++)
            {
                str2 = str2 + StringType.FromChar(Strings.Chr(Strings.Asc(Strings.Mid(inStr, (num6 + 1) - i, 1)) - num2));
                if (num2 == (num3 + num5))
                {
                    num2 = num4 + num5;
                }
                else
                {
                    num2 = num3 + num5;
                }
            }
            return(str2 + Strings.Space(Strings.Len(inStr) - num6));
        }
Esempio n. 5
0
        public string CantidadEnLetras()
        {
            int    num4 = 0;
            int    num5;
            int    num6;
            int    num7;
            int    num3 = 0;
            string str  = "";
            string str2 = Strings.Format(this._Cantidad, "f3");
            int    num9 = str2.Length - 4;
            int    num  = num9 % 3;

            if (((num9 / 3) == 0) | (num != 0))
            {
                if (num == 1)
                {
                    num4 = IntegerType.FromString(StringType.FromChar(str2[0]));
                    str  = this.Leer(num4) + " ";
                    num3 = 1;
                }
                if (num == 2)
                {
                    num4 = IntegerType.FromString(StringType.FromChar(str2[0]));
                    num5 = IntegerType.FromString(StringType.FromChar(str2[1]));
                    num6 = (num4 * 10) + num5;
                    if (StringType.StrCmp(this.Leer(num6), "", false) == 0)
                    {
                        num7 = num4 * 10;
                        str  = this.Leer(num7) + " y " + this.Leer(num5) + " ";
                    }
                    else if (StringType.StrCmp(this.Leer(num6), "cero", false) != 0)
                    {
                        str = this.Leer(num6) + " ";
                    }
                    num3 = 2;
                }
            }
            if (((num9 / 3) == 1) & (num3 != 0))
            {
                str = str + "mil ";
            }
            if ((((num9 / 3) == 2) & (num3 != 0)) & (num4 == 1))
            {
                str = str + "millon ";
            }
            else if (((num9 / 3) == 2) & (num3 != 0))
            {
                str = str + "millones ";
            }
            int num10 = num9 / 3;

            for (int i = 1; i <= num10; i++)
            {
                string cadena = StringType.FromChar(str2[num3]) + StringType.FromChar(str2[num3 + 1]) + StringType.FromChar(str2[num3 + 2]);
                num4 = this.Convertir(cadena);
                if (StringType.StrCmp(this.Leer(num4), "", false) == 0)
                {
                    num5 = IntegerType.FromString(StringType.FromChar(str2[num3])) * 100;
                    if ((StringType.StrCmp(this.Leer(num5), "cero", false) != 0) & (num5 == 100))
                    {
                        str = str + this.Leer(num5) + "to ";
                    }
                    else if (StringType.StrCmp(this.Leer(num5), "cero", false) != 0)
                    {
                        str = str + this.Leer(num5) + " ";
                    }
                    num6 = IntegerType.FromString(StringType.FromChar(str2[num3 + 1])) * 10;
                    num7 = IntegerType.FromString(StringType.FromChar(str2[num3 + 2]));
                    int numero = num6 + num7;
                    if (StringType.StrCmp(this.Leer(numero), "", false) == 0)
                    {
                        str = str + this.Leer(num6) + " y " + this.Leer(num7) + " ";
                    }
                    else if (StringType.StrCmp(this.Leer(numero), "cero", false) != 0)
                    {
                        str = str + this.Leer(numero) + " ";
                    }
                }
                else if (StringType.StrCmp(this.Leer(num4), "cero", false) != 0)
                {
                    str = str + this.Leer(num4) + " ";
                }
                if ((((num9 / 3) == 2) & (i == 1)) & (num4 != 0))
                {
                    str = str + "mil ";
                }
                if ((((num9 / 3) == 3) & (i == 1)) & (num4 != 0))
                {
                    str = str + "millones ";
                }
                if ((((num9 / 3) == 3) & (i == 2)) & (num4 != 0))
                {
                    str = str + "mil ";
                }
                num3 += 3;
            }
            return((str + "pesos " + StringType.FromChar(str2[num3 + 1]) + StringType.FromChar(str2[num3 + 2]) + "/100 MN").ToUpper());
        }
Esempio n. 6
0
 public void FromChar(char value, string expected)
 {
     Assert.Equal(expected, StringType.FromChar(value));
 }
Esempio n. 7
0
        private string WriteAndReadFromUPS(string Comando, bool NaoEsperaResposta = false)
        {
            if (!Conectado())
            {
                throw new NobreakNotConnectedException();
            }

            FileIOApiDeclarations.SECURITY_ATTRIBUTES lpSecurityAttributes = new FileIOApiDeclarations.SECURITY_ATTRIBUTES();
            MyHID.Capabilities = MyHID.GetDeviceCapabilities(HIDHandle);
            WriteHandle        = FileIOApiDeclarations.CreateFile(MyDevicePathName, 1073741824, 3, ref lpSecurityAttributes, 3, 0, 0);
            ReadHandle         = FileIOApiDeclarations.CreateFile(MyDevicePathName, int.MinValue, 3, ref lpSecurityAttributes, 3, 1073741824, 0);

            string str = "Str";

            try
            {
                bool flag = false;
                if (ReadHandle != -1 & WriteHandle != -1)
                {
                    if ((int)MyHID.Capabilities.OutputReportByteLength > 0)
                    {
                        byte[] reportBuffer = new byte[checked ((int)MyHID.Capabilities.OutputReportByteLength - 1 + 1)];
                        reportBuffer[0] = (byte)0;
                        if (Information.UBound((Array)reportBuffer, 1) > 1)
                        {
                            reportBuffer[1] = checked ((byte)Strings.Len(Comando));
                            int num1  = 1;
                            int num2  = Strings.Len(Comando);
                            int Start = num1;
                            while (Start <= num2)
                            {
                                reportBuffer[checked (Start + 1)] = checked ((byte)Strings.Asc(Strings.Mid(Comando, Start, 1)));
                                checked { ++Start; }
                            }
                        }
                        flag = myOutputReport.Write(reportBuffer, WriteHandle);
                        if (!flag)
                        {
                            MyDeviceDetected = false;
                        }
                    }
                    string Expression1 = "Expression 1";
                    if (!NaoEsperaResposta & flag)
                    {
                        Expression1 = "";
                        int  num1 = 0;
                        bool success;
                        do
                        {
                            success = false;
                            if ((int)MyHID.Capabilities.InputReportByteLength > 0)
                            {
                                byte[] readBuffer = new byte[checked ((int)MyHID.Capabilities.InputReportByteLength - 1 + 1)];
                                myInputReport.Read(ReadHandle, HIDHandle, WriteHandle, ref MyDeviceDetected, ref readBuffer, ref success);
                                if (success)
                                {
                                    string Expression2 = Expression1;
                                    int    num2        = 1;
                                    int    num3        = (int)readBuffer[1];
                                    int    num4        = num2;
                                    while (num4 <= num3)
                                    {
                                        if ((int)readBuffer[checked (num4 + 1)] != 0)
                                        {
                                            Expression1 += StringType.FromChar(Strings.Chr((int)readBuffer[checked (num4 + 1)]));
                                        }
                                        checked { ++num4; }
                                    }
                                    if (Strings.Len(Expression1) == Strings.Len(Expression2) | Strings.Len(Expression1) == 47 & StringType.StrCmp(Comando, "Q1\r", false) == 0 | Strings.Len(Expression1) == 22 & StringType.StrCmp(Comando, "F\r", false) == 0)
                                    {
                                        checked { ++num1; }
                                    }
                                    else
                                    {
                                        num1 = 0;
                                    }
                                }
                                else
                                {
                                    MyDeviceDetected = false;
                                }
                            }
                        }while (success & num1 < 1);
                    }
                    str = Expression1;
                }
            }

            catch (NobreakNotConnectedException)
            {
                Debug.WriteLine("Nobreak nao conectado para executar COMANDO");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                //frmMonitor.HandleException(Name, ex);
                ProjectData.ClearProjectError();
                Console.WriteLine("ERRO> " + ex.Message);
            }


            return(str);
        }