Hello! Is there a version with Unicode support?
Or tell me how to fix it.
From the message just me I did not understand how to do it.
BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
As I understand it, you need to change only CONVERT_TO_BYTE_ENCODING?
Re: BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
Great script!
The following function enable scripts to support Kanji (Japanese/Korean/Chinese Characters) encoding
This is a test example
The following function enable scripts to support Kanji (Japanese/Korean/Chinese Characters) encoding
Code: Select all
Kanji_encode(str)
{
tmp := StrSplit(str)
for k,v in tmp
{
c := Asc(v)
If ((c >= 0x0001) && (c <= 0x007F))
out .= v
Else if (c > 0x07FF)
{
out .= Chr(0xE0 | ((c >> 12) & 0x0F))
out .= Chr(0x80 | ((c >> 6) & 0x3F))
out .= Chr(0x80 | ((c >> 0) & 0x3F))
}
Else
{
out .= Chr(0xC0 | ((c >> 6) & 0x1F))
out .= Chr(0x80 | ((c >> 0) & 0x3F))
}
}
Return out
}
Code: Select all
#SingleInstance, Force
SetBatchLines, -1
START:
InputBox, test ,, Type in a message and a corresponding QR Code image will be generated and saved in the scripts directory.,,,,,,,,Test Example,测试例子,테스트 예,テスト例
Kanji_encode(str)
{
tmp := StrSplit(str)
for k,v in tmp
{
c := Asc(v)
If ((c >= 0x0001) && (c <= 0x007F))
out .= v
Else if (c > 0x07FF)
{
out .= Chr(0xE0 | ((c >> 12) & 0x0F))
out .= Chr(0x80 | ((c >> 6) & 0x3F))
out .= Chr(0x80 | ((c >> 0) & 0x3F))
}
Else
{
out .= Chr(0xC0 | ((c >> 6) & 0x1F))
out .= Chr(0x80 | ((c >> 0) & 0x3F))
}
}
Return out
}
MATRIX_TO_PRINT := BARCODER_GENERATE_QR_CODE(Kanji_encode(test))
if (MATRIX_TO_PRINT = 1)
{
Msgbox, 0x10, Error, The input message is blank. Please input a message to succesfully generate a QR Code image.
Goto START
}
If MATRIX_TO_PRINT between 1 and 7
{
Msgbox, 0x10, Error, ERROR CODE: %MATRIX_TO_PRINT% `n`nERROR CODE TABLE:`n`n1 - Input message is blank.`n2 - The Choosen Code Mode cannot encode all the characters in the input message.`n3 - Choosen Code Mode does not correspond to one of the currently indexed code modes (Automatic, numeric, alphanumeric or byte).`n4 - The choosen forced QR Matrix version (size) cannot encode the entire input message using the choosen ECL Code_Mode. Try forcing a higher version or choosing automated version selection (parameter value 0).`n5 - The input message is exceeding the QR Code standards maximum length for the choosen ECL and Code Mode.`n6 - Choosen Error Correction Level does not correspond to one of the standard ECLs (L, M, Q and H).`n7 - Forced version does not correspond to one of the QR Code standards versions.
Goto START
}
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
pBitmap := Gdip_CreateBitmap(MATRIX_TO_PRINT.MaxIndex() + 8, MATRIX_TO_PRINT.MaxIndex() + 8) ; Adding 8 pixels to the width and height here as a "quiet zone" for the image. This serves to improve the printed code readability. QR Code specs require the quiet zones to surround the whole image and to be at least 4 modules wide (4 on each side = 8 total width added to the image). Don't forget to increase this number accordingly if you plan to change the pixel size of each module.
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(pBitmap, 3)
pBrush := Gdip_BrushCreateSolid(0xFFFFFFFF)
Gdip_FillRectangle(G, pBrush, 0, 0, MATRIX_TO_PRINT.MaxIndex() + 8, MATRIX_TO_PRINT.MaxIndex() + 8) ; Same as above.
Gdip_DeleteBrush(pBrush)
Loop % MATRIX_TO_PRINT.MaxIndex() ; Acess the Rows of the Matrix
{
CURRENT_ROW := A_Index
Loop % MATRIX_TO_PRINT[1].MaxIndex() ; Access the modules (Columns of the Rows).
{
If (MATRIX_TO_PRINT[CURRENT_ROW, A_Index] = 1)
{
Gdip_SetPixel(pBitmap, A_Index + 3, CURRENT_ROW + 3, 0xFF000000) ; Adding 3 to the current column and row to skip the quiet zones.
}
}
}
StringReplace, FILE_NAME_TO_USE, test, `" ; We can't use all the characters that byte mode can encode in the name of the file. So we are replacing them here (if they exist).
FILE_PATH_AND_NAME := A_ScriptDir . "\" . SubStr(RegExReplace(FILE_NAME_TO_USE, "[\t\r\n\\\/\`:\`?\`*\`|\`>\`<]"), 1, 20) . ".png" ; Same as above. We will only use the first 20 characters for the file name in this example.
Gdip_SaveBitmapToFile(pBitmap, FILE_PATH_AND_NAME)
Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
MsgBox,0,Success,Created QR Code in file`n%FILE_PATH_AND_NAME%
Goto START
Return
#Include %A_ScriptDir%/BARCODER.ahk
#Include %A_ScriptDir%/Gdip_All.ahk
Re: BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
Thanks for the feedback Zhang, and thank you for your contribution on Kanji. I will add a reference to your post in the OP
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Re: BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
i Know this is an old topic, but how would you use this to store a username and password to login a system? Thank you. I mean like, how dr's just show their card to the computer and it logs them in?
Re: BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
Don't worry, no rules against "necro-posting" here
I think you can use the text/string of the QRcode and use it as the encryption key. Or have the QRcode structured with something like username:password but it would be risky for security since someone who takes a picture of the card... You could enrypt using something like a key-pairs like PGP, but still...
I defer to others here
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: BARCODER - Create 1D and 2D Barcodes (QRCode , C39,etc)
Joe pretty much nailed it.
I have seen the following routine though: Supermarket cashier has to log in using a password (not in the card) early on in the day and then (after this primary login) he/she uses a QRCode Card for "secondary logins" to ensure that he/she "is in that station" whenever a new customer arrives at the cashier. Might this be what you have seen?
Main concern is that regular QR Codes are quite easy to copy. Just take a picture of it with a smartphone and then you can activate a scanner from the smartphones screen (displaying the picture). For this reason, a login routine fully based on a Card with a QR Code would probably be restricted to very specific situations (i.e. user has no access to any data, but merely inputs into a form and the login routine is merely to know who created that register).
That being said, magnetic cards are not totally copy-proof either and UV QR Codes (printed using invisible UV paint and then scanneed only with a UV scanners) might take the security up a bit. Quite sure these have been used in night clubs to track paying customers (all-inclusive, etc. QR Codes are painted onto their skin using UV paint).
Source: https://cdn.hackaday.io/images/4028761540321776743.jpg
Proper consideration of security needs in the routine is a must in ANY case.
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey