Пример #1
0
 private bool parseNumber()
 {
     this.debug = true;
     if (!string.IsNullOrEmpty(this.txtPhoneNumber.Text))
     {
         try
         {
             this.number = this.txtPhoneNumber.Text;
             this.TrimNumber();
             PhoneNumber phoneNumber = new PhoneNumber(this.number);
             this.identity = WhatsRegisterV2.GenerateIdentity((string)phoneNumber.Number, "");
             this.cc       = (string)phoneNumber.CC;
             this.phone    = (string)phoneNumber.Number;
             CountryHelper countryHelper = new CountryHelper();
             string        country       = string.Empty;
             if (countryHelper.CheckFormat(this.cc, this.phone, out country))
             {
                 return(true);
             }
             this.Notify(string.Format("Provided number does not match any known patterns for {0}", (object)country));
             return(false);
         }
         catch (Exception ex)
         {
             this.Notify(string.Format("Error: {0}", (object)ex.Message));
         }
     }
     else
     {
         this.Notify("Please enter a phone number");
     }
     return(false);
 }
Пример #2
0
        private static void RegisterAccount()
        {
            Console.Write("CountryCode (ex. 31): ");
            string countryCode = Console.ReadLine();

            Console.Write("Phonenumber (ex. 650568134): ");
            string phoneNumber = Console.ReadLine();
            string password    = null;

            if (!WhatsRegisterV2.RequestCode(countryCode, phoneNumber, out password))
            {
                return;
            }
            Console.Write("Enter received code: ");
            string tmpCode = Console.ReadLine();

            password = WhatsRegisterV2.RegisterCode(countryCode, phoneNumber, tmpCode);
            if (String.IsNullOrEmpty(password))
            {
                Console.WriteLine("Error registering code");
            }
            else
            {
                Console.WriteLine(String.Format("Registration succesful. Password = {0}", password));
            }
            Console.ReadLine();
        }
Пример #3
0
        private bool _requestCode(out string response)
        {
            string str1 = (string)null;
            bool   flag = WhatsRegisterV2.RequestCode(this.number, out this.password, out str1, out response, this.method, this.identity);

            MessageBox.Show(str1 + "!!!!" + response);
            textBox2.Text = str1;
            if (this.debug)
            {
                string   format   = "Code Request:\nToken = {0}\nIdentity = {1}\nUser Agent = {2}\nRequest = {3}\nResponse = {4}";
                object[] objArray = new object[5];
                int      index1   = 0;
                string   token    = WhatsRegisterV2.GetToken(this.phone);
                objArray[index1] = (object)token;
                int    index2 = 1;
                string str2   = this.identity;
                objArray[index2] = (object)str2;
                int    index3 = 2;
                string str3   = "WhatsApp/2.12.81 S40Version/14.26 Device/Nokia302";
                objArray[index3] = (object)str3;
                int    index4 = 3;
                string str4   = str1;
                objArray[index4] = (object)str4;
                int    index5 = 4;
                string str5   = response;
                objArray[index5] = (object)str5;
                this.Notify(string.Format(format, objArray));
            }
            if (flag)
            {
                if (!string.IsNullOrEmpty(this.password))
                {
                    this.OnReceivePassword();
                }
                else
                {
                    this.grpStep1.Enabled = false;
                    this.grpStep2.Enabled = true;
                    this.Notify(string.Format("Code sent by {0} to {1}", (object)this.method, (object)this.number));
                }
            }
            return(flag);
        }
Пример #4
0
        private void btnRegisterCode_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtCode.Text) || this.txtCode.Text.Length != 6)
            {
                return;
            }
            this.code = this.txtCode.Text;
            string str1 = string.Empty;

            this.password = WhatsRegisterV2.RegisterCode(this.number, this.code, out str1, this.identity);
            MessageBox.Show(str1);
            if (this.debug)
            {
                string   format   = "Code register:\nCode = {0}\nNumber = {1}\nIdentity = {2}\nResponse = {3}";
                object[] objArray = new object[4];
                int      index1   = 0;
                string   str2     = this.code;
                objArray[index1] = (object)str2;
                int    index2 = 1;
                string str3   = this.number;
                objArray[index2] = (object)str3;
                int    index3 = 2;
                string str4   = this.identity;
                objArray[index3] = (object)str4;
                int    index4 = 3;
                string str5   = str1;
                objArray[index4] = (object)str5;
                this.Notify(string.Format(format, objArray));
            }
            if (!string.IsNullOrEmpty(this.password))
            {
                this.OnReceivePassword();
            }
            else
            {
                this.Notify("Verification code not accepted");
            }
        }