Example #1
0
        /// <summary>
        /// wifi
        /// </summary>
        protected void QR_wifi()
        {
            WiFi   generator = new WiFi("Wifi_Name", "Wifi_Password", WiFi.Authentication.WPA);
            string payload   = generator.ToString();

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);

            QR            = qrCode.GetGraphic(4, Color.Red, Color.Green, (Bitmap)Bitmap.FromFile("D:\\1122\\02\\NG\\1 (1).jpg"));
            QR_show.Image = QR.GetThumbnailImage(300, 300, null, IntPtr.Zero);
        }
Example #2
0
        private void btnTulsaGen_Click(object sender, RoutedEventArgs e)
        {
            WiFi   generator = new WiFi("brenternet_att", "katieanna", WiFi.Authentication.WPA);
            string payload   = generator.ToString();

            QRCodeGenerator qrGenerator    = new QRCodeGenerator();
            QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode         = new QRCode(qrCodeData);
            Bitmap          qrCodeAsBitmap = qrCode.GetGraphic(20);

            imgTulsa.BeginInit();
            imgTulsa.Source = BitmapToImageSource(qrCodeAsBitmap);
            imgTulsa.EndInit();
        }
Example #3
0
        private void btnNormanGen_Click(object sender, RoutedEventArgs e)
        {
            WiFi   generator = new WiFi("katiejordan", "blackbanana1", WiFi.Authentication.WPA);
            string payload   = generator.ToString();

            QRCodeGenerator qrGenerator    = new QRCodeGenerator();
            QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode         = new QRCode(qrCodeData);
            Bitmap          qrCodeAsBitmap = qrCode.GetGraphic(20);

            imgNorman.BeginInit();
            imgNorman.Source = BitmapToImageSource(qrCodeAsBitmap);
            imgNorman.EndInit();
        }
        private void generateQR()
        {
            barcodegcode = "";
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData;

            if (tCQRPayload.SelectedIndex == 0)
            {
                Logger.Trace("TabControl 0");
                qrCodeData = qrGenerator.CreateQrCode(tBQRText.Text, QRCodeGenerator.ECCLevel.Q);
            }
            else if (tCQRPayload.SelectedIndex == 1)
            {
                Logger.Trace("TabControl 1");
                Url    generator = new Url(tBQRURL.Text);
                string payload   = generator.ToString();
                qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            }
            else //if (tCQRPayload.SelectedIndex == 2)
            {
                Logger.Trace("TabControl 2");
                WiFi.Authentication auth = WiFi.Authentication.nopass;
                if (rBWLAN1.Checked)
                {
                    auth = WiFi.Authentication.WPA;
                }
                if (rBWLAN2.Checked)
                {
                    auth = WiFi.Authentication.WEP;
                }
                WiFi   generator = new WiFi(tBWLAN1.Text, tBWLAN2.Text, auth, cBWLAN1.Checked);
                string payload   = generator.ToString();
                qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            }


            QRCode qrCode = new QRCode(qrCodeData);

            if (cBInsertLogo.Checked)
            {
                qrCodeImage = qrCode.GetGraphic((int)Properties.Settings.Default.importBarcode2DLines, System.Drawing.Color.Black, System.Drawing.Color.White, (System.Drawing.Bitmap)pictureBox3.Image);
            }
            else
            {
                qrCodeImage = qrCode.GetGraphic((int)Properties.Settings.Default.importBarcode2DLines); // pixel per module
            }
            pictureBox2.Image             = qrCodeImage;
            btnClipboardBarcode2D.Visible = true;
        }
        public IActionResult GetWIFIQRCode(int pixel)
        {
            if (pixel <= 0)
            {
                return(BadRequest("pixel <= 0"));
            }

            var payload = new WiFi("ssid", "password", WiFi.Authentication.WPA);
            var bitmap  = _qrCode.GetQRCode(payload.ToString(), pixel);
            var ms      = new MemoryStream();

            bitmap.Save(ms, ImageFormat.Jpeg);

            return(File(ms.GetBuffer(), "image/jpeg"));
        }
Example #6
0
        public void GenerateWIFIQR(System.Windows.Controls.Image imageViewer)
        {
            string ssid     = mainWindow.wifiData.WifiSSID;
            string password = mainWindow.wifiData.WifiPassword;

            SpongeQR.Types.WIFIAuthTypes authMode = mainWindow.wifiData.WifiAuthType;

            WiFi.Authentication auth = CheckWIFIAuthTypeSelected(authMode);

            WiFi generator = new WiFi(ssid, password, auth);

            string payload = generator.ToString();

            Console.WriteLine(payload);

            QRCode qrCode = GenerateQRData(payload);

            ConvertBitmapToSourceAndDisplay(qrCodeImage, qrCode, Bitmapsource, imageViewer);
        }
Example #7
0
        static void Main(string[] args)
        {
            var    parser   = new FluentCommandLineParser();
            string ssid     = "";
            string password = "";
            string filename = "wifi.png";

            parser.IsCaseSensitive = false;
            parser
            .Setup <string>('s', "SSID")
            .Callback(v => ssid = v)
            .Required();
            parser.Setup <string>('p', "password")
            .Callback(v => password = v);
            parser.Setup <string>('f', "filename")
            .Callback(v => filename = v);
            var result = parser.Parse(args);

            if (result.HasErrors)
            {
                Console.Error.WriteLine(result.ErrorText);
            }
            else
            {
                var obfuscatedPassword = string.Join(
                    string.Empty,
                    Enumerable.Repeat('*', password.Length));
                Console.WriteLine($"{ssid}:{obfuscatedPassword}");
            }

            WiFi   generator = new WiFi(ssid, password, WiFi.Authentication.WPA);
            string payload   = generator.ToString();

            QRCodeGenerator qrGenerator    = new QRCodeGenerator();
            QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode         = new QRCode(qrCodeData);
            var             qrCodeAsBitmap = qrCode.GetGraphic(20);

            qrCodeAsBitmap.Save(filename, ImageFormat.Png);
        }
Example #8
0
        private void GenerateQRForWifi(string name, string password, string auth)
        {
            try
            {
                using (FolderBrowserDialog f = new FolderBrowserDialog())
                {
                    // if this is empty then this will not execute :
                    // TODO : Check the pass only on WPA or WEP
                    if (auth == "nopass")
                    {
                        WiFi   generator = new WiFi(name, password, WiFi.Authentication.nopass);
                        string payload   = generator.ToString();

                        QRCodeGenerator qrGenerator    = new QRCodeGenerator();
                        QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
                        QRCode          qrCode         = new QRCode(qrCodeData);
                        Bitmap          qrCodeAsBitmap = qrCode.GetGraphic(20);

                        if (save_image_wifi == true)
                        {
                            if (f.ShowDialog() == DialogResult.OK)
                            {
                                qrCodeAsBitmap.Save(Path.Combine(f.SelectedPath, "qr-code-wifi-no-pass.png"));
                            }
                        }

                        pictureBoxWifi.Image = qrCodeAsBitmap;

                        //free ram
                        qrGenerator.Dispose();
                        qrCodeData.Dispose();
                        qrCode.Dispose();
                        Clear();
                    }
                    else if (auth == "WPA")
                    {
                        WiFi   generator = new WiFi(name, password, WiFi.Authentication.WPA);
                        string payload   = generator.ToString();

                        QRCodeGenerator qrGenerator    = new QRCodeGenerator();
                        QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
                        QRCode          qrCode         = new QRCode(qrCodeData);
                        Bitmap          qrCodeAsBitmap = qrCode.GetGraphic(20);

                        if (save_image_wifi == true)
                        {
                            if (f.ShowDialog() == DialogResult.OK)
                            {
                                qrCodeAsBitmap.Save(Path.Combine(f.SelectedPath, "qr-code-wifi-pass.png"));
                            }
                        }
                        pictureBoxWifi.Image = qrCodeAsBitmap;
                        qrGenerator.Dispose();
                        qrCodeData.Dispose();
                        qrCode.Dispose();
                        Clear();
                    }
                    else if (auth == "WEP")
                    {
                        WiFi   generator = new WiFi(name, password, WiFi.Authentication.WEP);
                        string payload   = generator.ToString();

                        QRCodeGenerator qrGenerator    = new QRCodeGenerator();
                        QRCodeData      qrCodeData     = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
                        QRCode          qrCode         = new QRCode(qrCodeData);
                        Bitmap          qrCodeAsBitmap = qrCode.GetGraphic(20);

                        if (save_image_wifi == true)
                        {
                            if (f.ShowDialog() == DialogResult.OK)
                            {
                                qrCodeAsBitmap.Save(Path.Combine(f.SelectedPath, "qr-code-wifi-pass.png"));
                            }
                        }

                        pictureBoxWifi.Image = qrCodeAsBitmap;

                        qrGenerator.Dispose();
                        qrCodeData.Dispose();
                        qrCode.Dispose();
                        Clear();
                    }
                }
            }
            catch (Exception e)
            {
                MetroSetMessageBox.Show(this, "An error : " + e.Message, "QR Creator");
            }
        }