QR code and barcode
qr createqr createqr to_base64qr to_base64qr to_svgqr to_svgqr readqr readqr epcqr epcqr epc_payloadqr wifi_payloadbarcode createbarcode createbarcode to_base64barcode to_base64barcode readbarcode readbarcode read_allbarcode check_digittotp secrettotp secrettotp codetotp codetotp verifytotp verifytotp uritotp urihotp codehotp codehotp verifyhotp verify

qr create <text> <out_path>


Description

    Write a QR code in a file with the default parameters (300 pixels, margin 4, ecc M). Returns the JSON {path, width, height, modules, version, ecc, bytes}. A text with non ASCII characters is encoded in UTF-8 with an ECI header

Parameters

    text:   The text to encode (2953 bytes at most with ecc L, 1273 with H) - String - required
    out_path:   The file to write: its extension gives the format (.png, .jpg, .gif, .bmp, .svg) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (qr create "https://www.mentdb.org" "tmp/tuto_etl/code/qr.png"); -> "[res]" (concat "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height") ", " "modules " (json select "tuto_c" "/modules") ", " "version " (json select "tuto_c" "/version") ", " "ecc " (json select "tuto_c" "/ecc")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
width 300, height 300, modules 25, version 2, ecc M
Complete: in SVG
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (qr create "https://www.mentdb.org" "tmp/tuto_etl/code/qr.svg"); -> "[res]" (concat "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height") ", " "modules " (json select "tuto_c" "/modules") ", " "version " (json select "tuto_c" "/version") ", " "ecc " (json select "tuto_c" "/ecc")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
width 300, height 300, modules 25, version 2, ecc M

qr create <text> <out_path> <json_params>


Description

    Write a QR code with parameters: size (pixels, 300, 1 to 4096; the image grows when a module would have less than 2 pixels; width and height give the real size), margin (quiet zone in modules, 4, 0 to 64), ecc (L, M, Q or H, M by default), color and background (#RRGGBB, #RRGGBBAA, a name; background can be transparent on png and svg), logo (the path of an image put at the center on a white pad, ecc is forced to H, the version is 5 at least, the pad covers 20% of the code at most and is reduced until the code is read back, or an error)

Parameters

    text:   The text to encode (2953 bytes at most with ecc L, 1273 with H) - String - required
    out_path:   The file to write: its extension gives the format (.png, .jpg, .gif, .bmp, .svg) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (qr create "Bonjour" "tmp/tuto_etl/code/qr.png" "{\"size\": 400, \"margin\": 2, \"ecc\": \"H\", \"color\": \"#102060\", \"background\": \"#FFFFF0\"}"); -> "[res]" (concat "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height") ", " "modules " (json select "tuto_c" "/modules") ", " "version " (json select "tuto_c" "/version") ", " "ecc " (json select "tuto_c" "/ecc")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
width 400, height 400, modules 21, version 1, ecc H
Complete: a logo at the center, then the code is read
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; image from_base64 "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAABQCAYAAADSm7GJAAACNUlEQVR4Xu2Rwc3WQBTEKIIzhVEnRVAOHYBy+CXk0/eS3XESjSVfk53nbz9+/v5b92vxjQ+pe7Ro4JAWDRzSooFDWjRwSIsGDmnRwCEtGjikRQOHtGjgkBYNHNKigUNaNHBIiwYOadHAIS1uGfjPr++X5TdtLW4RmHF2yH+mtVADM0JCviGlRTwwD27Kt+3UIhqYB76DfOMuLSKBedQ7yjev1mJ7YB7yzvLtK7XYGpgHfILcsEqLbYF5uCfJLSu02BKYB3ui3HRVi+WBeagny21XtFgamAd6g9x4VotlgXmYN8mtZ7Ro4A/k1jNaLAnMg7xRbp5q0cAfys1TLRr4Q7l5qsXlwDzEm+X2iRYNPJDbJ1o08EBun2jRwAO5faJFAw/k9okWDTyQ2ydaNPBAbp9o0cADuX2iRQMP5PaJFg08kNsnWlwOfMhDvFFunmrRwB/KzVMtGvhDuXmqxZLAhzzIm+TWM1o08Ady6xktlgU+5GHeIDee1WJp4EMe6Mly2xUtlgc+5KGeKDdd1WJL4EMe7ElyywottgU+5OGeIDes0mJr4EMe8M7y7Su12B74kIe8o3zzai0igb/kUe8g37hLi2jgQx7YlG/bqUU88P/y4An5hpQWauAvGWGH/Gdai1sEpoxzRn7T1uKWgd+oRQOHtGjgkBYNHNKigUNaNHBIiwYOadHAIS0aOKRFA4e0aOCQFg0c0qKBQ1o0cEiLBg5p0cAhLRo4pEUDh7Ro4JAWDRzS4h8yp2L5HwYPogAAAABJRU5ErkJggg==" "tmp/tuto_etl/code/logo.png"; qr create "https://www.mentdb.org" "tmp/tuto_etl/code/qr.png" "{\"size\": 600, \"logo\": \"tmp/tuto_etl/code/logo.png\"}"; -> "[res]" (qr read "tmp/tuto_etl/code/qr.png"); file delete "tmp/tuto_etl/code"; [res]
mentdb
{"text": "https://www.mentdb.org", "format": "qr", "bytes": 22, "ecc": "H"}
Complete: too little contrast gives a warning in the result
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (qr create "Bonjour" "tmp/tuto_etl/code/qr.png" "{\"color\": \"#AAAAAA\"}"); -> "[res]" (concat "version " (json select "tuto_c" "/version") ", " "warning " (json select "tuto_c" "/warning")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
version 1, warning low contrast between the color and the background (2.32:1): some scanners may fail, 4.5:1 advised
Used in use cases (2 recipes)

    Integrator & ETL developer › Send an appointment and a contact that open in every calendar and phone
    Security engineer › Add a second factor to a login: secret, enrolment QR code, code check
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr read  ·  ics create  ·  ics parse  ·  string contains

qr to_base64 <text>


Description

    A QR code as a PNG data URI, for HTML or a JSON API

Parameters

    text:   The text to encode (2953 bytes at most with ecc L, 1273 with H) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string left (qr to_base64 "Bonjour") 40); file delete "tmp/tuto_etl/code"; [res]
mentdb
data:image/png;base64,iVBORw0KGgoAAAANSU

qr to_base64 <text> <json_params>


Description

    PNG data URI with parameters: size (pixels, 300, 1 to 4096; the image grows when a module would have less than 2 pixels; width and height give the real size), margin (quiet zone in modules, 4, 0 to 64), ecc (L, M, Q or H, M by default), color and background (#RRGGBB, #RRGGBBAA, a name; background can be transparent on png and svg), logo (the path of an image put at the center on a white pad, ecc is forced to H, the version is 5 at least, the pad covers 20% of the code at most and is reduced until the code is read back, or an error)

Parameters

    text:   The text to encode (2953 bytes at most with ecc L, 1273 with H) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[uri]" (qr to_base64 "Bonjour" "{\"size\": 120, \"ecc\": \"L\"}"); -> "[res]" (string left [uri] 22); file delete "tmp/tuto_etl/code"; [res]
mentdb
data:image/png;base64,

qr to_svg <text>


Description

    A QR code as an SVG string: one path, shape-rendering crispEdges, the same size at any zoom

Parameters

    text:   The text to encode (2953 bytes at most with ecc L, 1273 with H) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string left (qr to_svg "Bonjour") 90); file delete "tmp/tuto_etl/code"; [res]
mentdb
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300" height="300" viewBox="0

qr to_svg <text> <json_params>


Description

    SVG string with parameters: size (pixels, 300, 1 to 4096; the image grows when a module would have less than 2 pixels; width and height give the real size), margin (quiet zone in modules, 4, 0 to 64), ecc (L, M, Q or H, M by default), color and background (#RRGGBB, #RRGGBBAA, a name; background can be transparent on png and svg), logo (the path of an image put at the center on a white pad, ecc is forced to H, the version is 5 at least, the pad covers 20% of the code at most and is reduced until the code is read back, or an error). A logo is embedded as a PNG data URI

Parameters

    text:   The text to encode (2953 bytes at most with ecc L, 1273 with H) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string left (qr to_svg "Bonjour" "{\"background\": \"transparent\", \"size\": 200}") 90); file delete "tmp/tuto_etl/code"; [res]
mentdb
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="200" height="200" viewBox="0

qr read <image_path>


Description

    Read a QR code in an image: returns the JSON {text, format, bytes, ecc} (bytes: the length of the text in UTF-8). The image can be turned, and light on dark. No code found is an error; for several codes, see barcode read_all

Parameters

    image_path:   The image to read (png, jpg, gif, bmp, tiff, wbmp) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; qr create "Bonjour MentDB" "tmp/tuto_etl/code/qr.png"; -> "[res]" (qr read "tmp/tuto_etl/code/qr.png"); file delete "tmp/tuto_etl/code"; [res]
mentdb
{"text": "Bonjour MentDB", "format": "qr", "bytes": 14, "ecc": "M"}
Complete: a code turned by 90 degrees
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; qr create "Bonjour MentDB" "tmp/tuto_etl/code/qr.png"; image rotate "tmp/tuto_etl/code/qr.png" "tmp/tuto_etl/code/turned.png" 90; -> "[res]" (qr read "tmp/tuto_etl/code/turned.png"); file delete "tmp/tuto_etl/code"; [res]
mentdb
{"text": "Bonjour MentDB", "format": "qr", "bytes": 14, "ecc": "M"}

qr read <image_path> <json_params>


Description

    Read a QR code with parameters: try_harder (true: slower and more thorough)

Parameters

    image_path:   The image to read (png, jpg, gif, bmp, tiff, wbmp) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; qr create "Bonjour MentDB" "tmp/tuto_etl/code/qr.png"; -> "[res]" (qr read "tmp/tuto_etl/code/qr.png" "{\"try_harder\": false}"); file delete "tmp/tuto_etl/code"; [res]
mentdb
{"text": "Bonjour MentDB", "format": "qr", "bytes": 14, "ecc": "M"}
Used in use cases (3 recipes)

    Integrator & ETL developer › Send an appointment and a contact that open in every calendar and phone
    Accountant & manager › Print a payment QR code on an invoice: the customer scans it and the transfer is filled in
    Security engineer › Add a second factor to a login: secret, enrolment QR code, code check
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr create  ·  ics create  ·  ics parse  ·  qr epc

qr epc <json_payment> <out_path>


Description

    SEPA credit transfer QR code (EPC069-12, version 002, UTF-8, ecc M, 331 bytes at most, so version 13 at most): the banking apps fill the transfer when they scan it. The bytes are written without ECI header. Returns the same JSON as qr create

Parameters

    json_payment:   The payment: name (mandatory, 70 characters), iban (mandatory, checked), bic (optional, 8 or 11 characters), amount (optional, in EUR, 0.01 to 999999999.99, 2 decimals), purpose (optional, 1 to 4 characters), reference (structured, 35 characters) or text (140 characters), not both - String - required
    out_path:   The file to write: its extension gives the format (.png, .jpg, .gif, .bmp, .svg) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (qr epc "{\"name\": \"Association Les Amis\", \"iban\": \"FR7630006000011234567890189\", \"bic\": \"BNPAFRPP\", \"amount\": 25.5, \"text\": \"Cotisation 2026\"}" "tmp/tuto_etl/code/epc.png"); -> "[res]" (concat "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height") ", " "modules " (json select "tuto_c" "/modules") ", " "version " (json select "tuto_c" "/version") ", " "ecc " (json select "tuto_c" "/ecc")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
width 300, height 300, modules 41, version 6, ecc M

qr epc <json_payment> <out_path> <json_params>


Description

    SEPA QR code with parameters: size, margin, color, background (no logo and no other ecc: the standard requires M)

Parameters

    json_payment:   The payment: name (mandatory, 70 characters), iban (mandatory, checked), bic (optional, 8 or 11 characters), amount (optional, in EUR, 0.01 to 999999999.99, 2 decimals), purpose (optional, 1 to 4 characters), reference (structured, 35 characters) or text (140 characters), not both - String - required
    out_path:   The file to write: its extension gives the format (.png, .jpg, .gif, .bmp, .svg) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; qr epc "{\"name\": \"Association Les Amis\", \"iban\": \"FR7630006000011234567890189\", \"bic\": \"BNPAFRPP\", \"amount\": 25.5, \"text\": \"Cotisation 2026\"}" "tmp/tuto_etl/code/epc.png" "{\"size\": 500}"; json load "tuto_c" (qr read "tmp/tuto_etl/code/epc.png"); -> "[res]" (string left (json select "tuto_c" "/text") 12); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
BCD 002 1 SC
Used in use cases (1 recipe)

    Accountant & manager › Print a payment QR code on an invoice: the customer scans it and the transfer is filled in
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr epc_payload  ·  qr read  ·  string char  ·  string length

qr epc_payload <json_payment>


Description

    The text of a SEPA QR code, line by line: BCD, 002, 1, SCT, BIC, name, IBAN, amount, purpose, reference, text; the empty last lines are removed. The IBAN is written without spaces, its mod 97 key is checked. Control characters and line breaks are refused

Parameters

    json_payment:   The payment: name (mandatory, 70 characters), iban (mandatory, checked), bic (optional, 8 or 11 characters), amount (optional, in EUR, 0.01 to 999999999.99, 2 decimals), purpose (optional, 1 to 4 characters), reference (structured, 35 characters) or text (140 characters), not both - String - required
admin
qr epc_payload "{\"name\": \"Association Les Amis\", \"iban\": \"FR7630006000011234567890189\", \"bic\": \"BNPAFRPP\", \"amount\": 25.5, \"text\": \"Cotisation 2026\"}"
mentdb
BCD 002 1 SCT BNPAFRPP Association Les Amis FR7630006000011234567890189 EUR25.50 Cotisation 2026
the minimum: name and IBAN
admin
qr epc_payload "{\"name\": \"ACME\", \"iban\": \"FR76 3000 6000 0112 3456 7890 189\"}"
mentdb
BCD 002 1 SCT ACME FR7630006000011234567890189
a structured reference
admin
qr epc_payload "{\"name\": \"ACME\", \"iban\": \"FR7630006000011234567890189\", \"amount\": \"1200\", \"purpose\": \"SUPP\", \"reference\": \"RF18539007547034\"}"
mentdb
BCD 002 1 SCT ACME FR7630006000011234567890189 EUR1200.00 SUPP RF18539007547034
Used in use cases (1 recipe)

    Accountant & manager › Print a payment QR code on an invoice: the customer scans it and the transfer is filled in
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr epc  ·  qr read  ·  string char  ·  string length

qr wifi_payload <ssid> <password> <type>


Description

    The text of a Wi-Fi QR code: WIFI:T:type;S:ssid;P:password;; with the characters \ ; , : and " escaped by a backslash. Give it to qr create

Parameters

    ssid:   The name of the network (32 bytes at most) - String - required
    password:   The password (8 to 64 characters for WPA, empty for nopass) - String - required
    type:   WPA, WPA2, WPA3, SAE, WEP or nopass - String - required
admin
qr wifi_payload "Bureau" "motdepasse1" "WPA"
mentdb
WIFI:T:WPA;S:Bureau;P:motdepasse1;;
special characters are escaped
admin
qr wifi_payload "Bar;1" "a:b,c;d\"e" "WPA2"
mentdb
WIFI:T:WPA;S:Bar\;1;P:a\:b\,c\;d\"e;;
an open network
admin
qr wifi_payload "Invites" "" "nopass"
mentdb
WIFI:T:nopass;S:Invites;;

barcode create <type> <value> <out_path>


Description

    Write a barcode in a file. Returns the JSON {path, type, value, width, height, format, bytes}. ean13, ean8, upca and upce: without the check digit it is computed and added to value, with it it is verified. code128: ASCII. code39, code93: read back as written only with capital letters, digits and - . $ / + % space. itf: an even number of digits, 6 at least to be read. codabar: 0-9 - $ : / . +. upce: starts with 0 or 1. pdf417, datamatrix, aztec: any text

Parameters

    type:   code128, code39, code93, ean13, ean8, upca, upce, itf, codabar, pdf417, datamatrix or aztec - String - required
    value:   The value to encode - String - required
    out_path:   The file to write: its extension gives the format (.png, .jpg, .svg), unless the parameter format is given - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (barcode create "ean13" "590123412345" "tmp/tuto_etl/code/ean.png"); -> "[res]" (concat "type " (json select "tuto_c" "/type") ", " "value " (json select "tuto_c" "/value") ", " "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
type ean13, value 5901234123457, width 300, height 100
Complete: a Code 128 in SVG
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (barcode create "code128" "LOT-2026-001" "tmp/tuto_etl/code/lot.svg"); -> "[res]" (concat "type " (json select "tuto_c" "/type") ", " "value " (json select "tuto_c" "/value") ", " "format " (json select "tuto_c" "/format")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
type code128, value LOT-2026-001, format svg
Complete: a Data Matrix
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (barcode create "datamatrix" "Colis 12345" "tmp/tuto_etl/code/dm.png"); -> "[res]" (concat "type " (json select "tuto_c" "/type") ", " "value " (json select "tuto_c" "/value") ", " "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
type datamatrix, value Colis 12345, width 200, height 200

barcode create <type> <value> <out_path> <json_params>


Description

    Write a barcode with parameters: width and height (pixels; 300 x 100 for the bars, 200 x 200 for datamatrix and aztec, 400 x 160 for pdf417; the image grows when the code needs more), margin (quiet zone in modules: 10 for the bars, 2 for pdf417, datamatrix and aztec), text (true draws the value below the code, 120 characters at most), color, background, format (png, jpg or svg)

Parameters

    type:   code128, code39, code93, ean13, ean8, upca, upce, itf, codabar, pdf417, datamatrix or aztec - String - required
    value:   The value to encode - String - required
    out_path:   The file to write: its extension gives the format (.png, .jpg, .svg), unless the parameter format is given - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (barcode create "ean8" "9638507" "tmp/tuto_etl/code/ean8.png" "{\"width\": 400, \"height\": 160, \"text\": true}"); -> "[res]" (concat "type " (json select "tuto_c" "/type") ", " "value " (json select "tuto_c" "/value") ", " "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
type ean8, value 96385074, width 400, height 160
Complete: a PDF417 in JPEG
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; json load "tuto_c" (barcode create "pdf417" "Bon de livraison 8841" "tmp/tuto_etl/code/pdf.jpg" "{\"width\": 600, \"height\": 240}"); -> "[res]" (concat "type " (json select "tuto_c" "/type") ", " "width " (json select "tuto_c" "/width") ", " "height " (json select "tuto_c" "/height") ", " "format " (json select "tuto_c" "/format")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
type pdf417, width 600, height 240, format jpg

barcode to_base64 <type> <value>


Description

    A barcode as a PNG data URI

Parameters

    type:   code128, code39, code93, ean13, ean8, upca, upce, itf, codabar, pdf417, datamatrix or aztec - String - required
    value:   The value to encode - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string left (barcode to_base64 "code128" "ABC-123") 40); file delete "tmp/tuto_etl/code"; [res]
mentdb
data:image/png;base64,iVBORw0KGgoAAAANSU

barcode to_base64 <type> <value> <json_params>


Description

    A barcode as a data URI with parameters: width and height (pixels; 300 x 100 for the bars, 200 x 200 for datamatrix and aztec, 400 x 160 for pdf417; the image grows when the code needs more), margin (quiet zone in modules: 10 for the bars, 2 for pdf417, datamatrix and aztec), text (true draws the value below the code, 120 characters at most), color, background, format (png, jpg or svg)

Parameters

    type:   code128, code39, code93, ean13, ean8, upca, upce, itf, codabar, pdf417, datamatrix or aztec - String - required
    value:   The value to encode - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string left (barcode to_base64 "code128" "ABC-123" "{\"format\": \"svg\"}") 26); file delete "tmp/tuto_etl/code"; [res]
mentdb
data:image/svg+xml;base64,

barcode read <image_path>


Description

    Read one code of any type in an image (the QR codes too): returns the JSON {text, format, bytes}; format is the name of the type, or qr. A UPC-A is an EAN-13 starting with 0, and it is reported as upca. A codabar is read without its start and stop characters. No code found is an error

Parameters

    image_path:   The image to read (png, jpg, gif, bmp, tiff, wbmp) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; barcode create "ean13" "590123412345" "tmp/tuto_etl/code/ean.png"; -> "[res]" (barcode read "tmp/tuto_etl/code/ean.png"); file delete "tmp/tuto_etl/code"; [res]
mentdb
{"text": "5901234123457", "format": "ean13", "bytes": 13}

barcode read <image_path> <json_params>


Description

    Read a code with parameters: try_harder (true), formats (the types to search, ex: ["ean13", "qr"], fewer false detections and faster)

Parameters

    image_path:   The image to read (png, jpg, gif, bmp, tiff, wbmp) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; barcode create "code128" "LOT-2026-001" "tmp/tuto_etl/code/lot.png"; -> "[res]" (barcode read "tmp/tuto_etl/code/lot.png" "{\"formats\": [\"code128\"]}"); file delete "tmp/tuto_etl/code"; [res]
mentdb
{"text": "LOT-2026-001", "format": "code128", "bytes": 12}

barcode read_all <image_path>


Description

    Read all the codes of an image: JSON array of {text, format, bytes, x, y} from the top to the bottom, then from the left to the right; [] when there is none. Two codes with the same text count once. A Data Matrix or an Aztec code is only found alone in the image or in its zone: read a sheet with these codes zone by zone (image crop)

Parameters

    image_path:   The image to read (png, jpg, gif, bmp, tiff, wbmp) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; barcode create "code128" "LOT-1" "tmp/tuto_etl/code/a.png" "{\"width\": 200, \"height\": 120}"; qr create "QR-2" "tmp/tuto_etl/code/b.png" "{\"size\": 200}"; image grid "[\"tmp/tuto_etl/code/a.png\", \"tmp/tuto_etl/code/b.png\"]" "tmp/tuto_etl/code/sheet.png"; -> "[res]" (barcode read_all "tmp/tuto_etl/code/sheet.png"); file delete "tmp/tuto_etl/code"; [res]
mentdb
[{"text": "QR-2", "format": "qr", "bytes": 4, "x": 278, "y": 68}, {"text": "LOT-1", "format": "code128", "bytes": 5, "x": 71, "y": 110}]

barcode check_digit <type> <value>


Description

    The GS1 check digit: ean13 (12 digits), ean8 (7), upca (11), itf14 (13), gs1 (any length up to 17, ex: SSCC-18)

Parameters

    type:   ean13, ean8, upca, itf14 or gs1 - String - required
    value:   The digits without the check digit - String - required
admin
barcode check_digit "ean13" "590123412345"
mentdb
7
an ITF-14
admin
barcode check_digit "itf14" "1001234567890"
mentdb
2
an SSCC-18
admin
barcode check_digit "gs1" "10614141123456789"
mentdb
7

totp secret


Description

    A new random secret of 20 bytes in base32 (without padding), from a secure generator: 32 characters

admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string length (totp secret)); file delete "tmp/tuto_etl/code"; [res]
mentdb
32

totp secret <json_params>


Description

    A new random secret with parameters: bytes (16 to 64, 20)

Parameters

    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string length (totp secret "{\"bytes\": 32}")); file delete "tmp/tuto_etl/code"; [res]
mentdb
52

totp code <secret>


Description

    The current TOTP code of a secret (RFC 6238): 6 digits, 30 seconds, SHA-1, as Google Authenticator

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[res]" (string length (totp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ")); file delete "tmp/tuto_etl/code"; [res]
mentdb
6

totp code <secret> <json_params>


Description

    TOTP code with parameters: digits (6 to 10, 6), period (seconds, 30), algorithm (sha1, sha256 or sha512; many apps only know sha1), time (Unix seconds, the current time by default)

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    json_params:   The parameters - String - required
admin
totp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "{\"time\": 59}"
mentdb
287082
RFC 6238 test vector, 8 digits
admin
totp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "{\"time\": 1111111109, \"digits\": 8}"
mentdb
07081804
SHA-256
admin
totp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZA" "{\"time\": 59, \"digits\": 8, \"algorithm\": \"sha256\"}"
mentdb
46119246
Used in use cases (1 recipe)

    Security engineer › Add a second factor to a login: secret, enrolment QR code, code check
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr create  ·  qr read  ·  totp uri  ·  totp verify

totp verify <secret> <code>


Description

    Check a code at the current time with a window of one step before and after (clock differences): 1 or 0. Comparison in constant time. A code with a wrong format gives 0

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    code:   The code typed by the user - String - required
admin
totp verify "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "abc"
mentdb
0

totp verify <secret> <code> <json_params>


Description

    Check a code with parameters: window (steps accepted before and after, 1, 0 to 100), digits, period, algorithm, time

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    code:   The code - String - required
    json_params:   The parameters - String - required
admin
totp verify "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "287082" "{\"time\": 85}"
mentdb
1
without a window: refused
admin
totp verify "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "287082" "{\"time\": 85, \"window\": 0}"
mentdb
0
Used in use cases (1 recipe)

    Security engineer › Add a second factor to a login: secret, enrolment QR code, code check
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr create  ·  qr read  ·  totp code  ·  totp uri

totp uri <secret> <account> <issuer>


Description

    The otpauth:// URI to enrol a phone (Key URI format), URL-encoded; give it to qr create. The account and the issuer must not contain a colon. It contains the secret

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    account:   The account, ex: an email - String - required
    issuer:   The service - String - required
admin
totp uri "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "jean@exemple.fr" "ACME & Fils"
mentdb
otpauth://totp/ACME%20%26%20Fils:jean%40exemple.fr?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=ACME%20%26%20Fils&algorithm=SHA1&digits=6&period=30

totp uri <secret> <account> <issuer> <json_params>


Description

    The otpauth:// URI with parameters: digits, period, algorithm

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    account:   The account - String - required
    issuer:   The service - String - required
    json_params:   The parameters - String - required
admin
totp uri "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "jean@exemple.fr" "ACME" "{\"digits\": 8, \"algorithm\": \"sha256\"}"
mentdb
otpauth://totp/ACME:jean%40exemple.fr?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=ACME&algorithm=SHA256&digits=8&period=30
Complete: the URI in a QR code
admin
if (equal (file exist "tmp/tuto_etl/code") "0") {file mkdir "tmp/tuto_etl/code";}; -> "[uri]" (totp uri "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "jean@exemple.fr" "ACME"); json load "tuto_c" (qr create [uri] "tmp/tuto_etl/code/enrol.png"); -> "[res]" (concat "version " (json select "tuto_c" "/version") ", " "ecc " (json select "tuto_c" "/ecc")); json unload "tuto_c"; file delete "tmp/tuto_etl/code"; [res]
mentdb
version 8, ecc M
Used in use cases (1 recipe)

    Security engineer › Add a second factor to a login: secret, enrolment QR code, code check
Often used with

    equal  ·  file delete  ·  file exist  ·  file mkdir  ·  qr create  ·  qr read  ·  totp code  ·  totp verify

hotp code <secret> <counter>


Description

    The HOTP code of a counter (RFC 4226): 6 digits, SHA-1

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    counter:   The counter (0 to 999999999999999999) - Number - required
admin
hotp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" 0
mentdb
755224
counter 9
admin
hotp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" 9
mentdb
520489

hotp code <secret> <counter> <json_params>


Description

    HOTP code with parameters: digits (6 to 10), algorithm (sha1, sha256, sha512)

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    counter:   The counter - Number - required
    json_params:   The parameters - String - required
admin
hotp code "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" 1 "{\"digits\": 8}"
mentdb
94287082

hotp verify <secret> <code> <counter>


Description

    Check a HOTP code at a counter: JSON {valid, counter}; counter is the one that matched (store counter + 1 for the next time), or the one given

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    code:   The code - String - required
    counter:   The expected counter - Number - required
admin
hotp verify "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "755224" 0
mentdb
{"valid": true, "counter": 0}
a wrong code
admin
hotp verify "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "000000" 0
mentdb
{"valid": false, "counter": 0}

hotp verify <secret> <code> <counter> <json_params>


Description

    Check a HOTP code with parameters: window (look-ahead: the counters from counter to counter + window are tried, 0, up to 100), digits, algorithm

Parameters

    secret:   The shared secret in base32 (case and spaces ignored, padding optional) - String - required
    code:   The code - String - required
    counter:   The expected counter - Number - required
    json_params:   The parameters - String - required
admin
hotp verify "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" "969429" 0 "{\"window\": 5}"
mentdb
{"valid": true, "counter": 3}