From a1a95690e33bdbb7f271055792ac77a5d5734f1e Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 21 Jul 2021 22:56:54 +0200 Subject: [PATCH 1/4] Move ECCLevel to Enum --- QRCodeGenerator/2.6.0/New-PSOneQRCode.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QRCodeGenerator/2.6.0/New-PSOneQRCode.ps1 b/QRCodeGenerator/2.6.0/New-PSOneQRCode.ps1 index 870a15b..931808a 100644 --- a/QRCodeGenerator/2.6.0/New-PSOneQRCode.ps1 +++ b/QRCodeGenerator/2.6.0/New-PSOneQRCode.ps1 @@ -59,7 +59,7 @@ function New-PSOneQRCode $generator = New-Object -TypeName QRCoder.QRCodeGenerator - $data = $generator.CreateQrCode($payload, 'Q') + $data = $generator.CreateQrCode($payload, [QRCoder.QRCodeGenerator+ECCLevel]::Q) $code = new-object -TypeName QRCoder.PngByteQRCode -ArgumentList ($data) $byteArray = $code.GetGraphic($Width, $darkColorRgba, $lightColorRgba) [System.IO.File]::WriteAllBytes($outPath, $byteArray) From 26f51834c3c224ea7c14b37843b6096721048f12 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 21 Jul 2021 23:00:44 +0200 Subject: [PATCH 2/4] Create New-PSOneQRCodeWhatsAppMessage.ps1 --- .../2.6.0/New-PSOneQRCodeWhatsAppMessage.ps1 | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 QRCodeGenerator/2.6.0/New-PSOneQRCodeWhatsAppMessage.ps1 diff --git a/QRCodeGenerator/2.6.0/New-PSOneQRCodeWhatsAppMessage.ps1 b/QRCodeGenerator/2.6.0/New-PSOneQRCodeWhatsAppMessage.ps1 new file mode 100644 index 0000000..68392db --- /dev/null +++ b/QRCodeGenerator/2.6.0/New-PSOneQRCodeWhatsAppMessage.ps1 @@ -0,0 +1,58 @@ +function New-PSOneQRCodeWhatsAppMessage +{ + <# + .SYNOPSIS + Creates a QR code graphic containing a Whatsapp Message + + .DESCRIPTION + Creates a QR code graphic in png format that - when scanned by a smart device - opens a Whatsapp to send the defined Message + + .PARAMETER Text + The Text to send via WhatsApp + + .PARAMETER Show + Opens the generated QR code in associated program + + .PARAMETER OutPath + Path to generated png file. When omitted, a temporary file name is used. + + .EXAMPLE + New-PSOneQRCodeWhatsAppMessage -Text "Check out the following link: https://github.com/TobiasPSP/Modules.QRCodeGenerator" -Width 200 -Show -OutPath "$home\Desktop\qr.png" + Creates a QR code png graphics on your desktop, and opens it with the associated program + + .NOTES + Compatible with all PowerShell versions including PowerShell 6/Core + Uses binaries from https://github.com/codebude/QRCoder/wiki + + .LINK + https://github.com/TobiasPSP/Modules.QRCodeGenerator + #> + + [CmdletBinding()] + param + ( + [Parameter(Mandatory)] + [string] + $text, + + [ValidateRange(10,2000)] + [int] + $Width = 100, + + [Switch] + $Show, + + [string] + $OutPath = "$env:temp\qrcode.png", + + [byte[]] + $DarkColorRgba = @(0,0,0), + + [byte[]] + $LightColorRgba = @(255,255,255) + ) + + $payload = New-Object -TypeName QRCoder.PayloadGenerator+WhatsAppMessage -ArgumentList $text + + New-PSOneQRCode -payload $payload -Show $Show -Width $Width -OutPath $OutPath -darkColorRgba $darkColorRgba -lightColorRgba $lightColorRgba +} From 2a15f82be341d088efff1705bf9e563edcb10005 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 12 Oct 2021 20:49:41 +0200 Subject: [PATCH 3/4] [Update] WifiAccess to payload generator --- .../2.6.0/New-PSOneQRCodeWifiAccess.ps1 | 24 +++++++++++++++---- .../2.6.0/Types/PSOneQRCodeAuthentication.ps1 | 8 +++++++ QRCodeGenerator/2.6.0/loader.psm1 | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 QRCodeGenerator/2.6.0/Types/PSOneQRCodeAuthentication.ps1 diff --git a/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 b/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 index 104352d..7813e36 100644 --- a/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 +++ b/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 @@ -13,6 +13,10 @@ .PARAMETER Password The Wifi access point password + .PARAMETER AuthenticationMode + The Wifi access point Authentication Mode (nopass, WEP, WPA) + WPA also is WPA2 + .PARAMETER Width Height and Width of generated graphics (in pixels). Default is 100. @@ -41,10 +45,13 @@ [string] $SSID, - [Parameter(Mandatory)] [string] $Password, + [Parameter(Mandatory)] + [Authentication] + $AuthenticationMode, + [ValidateRange(10,2000)] [int] $Width = 100, @@ -62,9 +69,16 @@ $LightColorRgba = @(255,255,255) ) - $payload = @" -WIFI:S:$SSID;T:WPA2;P:$Password;; -"@ - + switch ($authenticationMode) { + WEP { $Authentication = [QRCoder.PayloadGenerator+WiFi+Authentication]::WEP; break} + WPA { $Authentication = [QRCoder.PayloadGenerator+WiFi+Authentication]::WPA; break} + Default { + $Authentication = [QRCoder.PayloadGenerator+WiFi+Authentication]::nopass + $password = "" + } + } + + $payload = New-Object -TypeName QRCoder.PayloadGenerator+WiFi -ArgumentList ($SSID, $password, $Authentication) + New-PSOneQRCode -payload $payload -Show $Show -Width $Width -OutPath $OutPath -darkColorRgba $darkColorRgba -lightColorRgba $lightColorRgba } diff --git a/QRCodeGenerator/2.6.0/Types/PSOneQRCodeAuthentication.ps1 b/QRCodeGenerator/2.6.0/Types/PSOneQRCodeAuthentication.ps1 new file mode 100644 index 0000000..10c848a --- /dev/null +++ b/QRCodeGenerator/2.6.0/Types/PSOneQRCodeAuthentication.ps1 @@ -0,0 +1,8 @@ +Add-Type -TypeDefinition @" +public enum Authentication +{ + nopass, + WEP, + WPA +} +"@ \ No newline at end of file diff --git a/QRCodeGenerator/2.6.0/loader.psm1 b/QRCodeGenerator/2.6.0/loader.psm1 index efd761f..761d839 100644 --- a/QRCodeGenerator/2.6.0/loader.psm1 +++ b/QRCodeGenerator/2.6.0/loader.psm1 @@ -7,6 +7,7 @@ $null = [System.Reflection.Assembly]::Load([System.Convert]::FromBase64String($c # LOADING ALL FUNCTION DEFINITIONS: . $PSScriptRoot\New-PSOneQRCodeVCard.ps1 . $PSScriptRoot\New-PSOneQRCodeGeolocation.ps1 +. $PSScriptRoot\Types\PSOneQRCodeAuthentication.ps1 . $PSScriptRoot\New-PSOneQRCodeWifiAccess.ps1 . $PSScriptRoot\New-PSOneQRCodeTwitter.ps1 . $PSScriptRoot\New-PSOneQRCodeText.ps1 From 13240f037df1eaa55da950e9c13b46cd11d9add1 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 12 Oct 2021 21:11:54 +0200 Subject: [PATCH 4/4] [fix] remove DefaultParameterSetName --- QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 b/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 index 7813e36..f638a48 100644 --- a/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 +++ b/QRCodeGenerator/2.6.0/New-PSOneQRCodeWifiAccess.ps1 @@ -38,7 +38,7 @@ https://github.com/TobiasPSP/Modules.QRCodeGenerator #> - [CmdletBinding(DefaultParameterSetName="Address")] + [CmdletBinding()] param ( [Parameter(Mandatory)]