Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    qrencode -t utf8 'WIFI:T:WPA;S:network;P:password;;'


If you want some interactivity (bash):

    read -rp "SSID: " ssid
    read -rsp "Password: " pass
    echo -e "\n"
    qrencode -t utf8 "WIFI:T:WPA;S:$ssid;P:$pass;;"
    echo "SSID: $ssid"
Even better, generate a PDF with emojis and all!

    #!/usr/bin/env bash
    out="${1:-wifi-card.pdf}"
    read -rp "SSID: " ssid
    read -rsp "Password: " pass
    echo -e "\nGenerating PDF..."
    {
    cat << EOF
    <table>
    <tr>
    <td><img src="data:image/png;base64,$(qrencode -o - -t png "WIFI:T:WPA;S:$ssid;P:$pass;;" | base64)"></td>
    <td><span>SSID: $ssid</span><br><span>Password: $pass</span></td>
    </tr>
    </table>
    <p>
    <img width=16 height=16 src="https://raw.githubusercontent.com/iamcal/emoji-data/master/img-apple-64/1f4f8.png">
    <img width=16 height=16 src="https://raw.githubusercontent.com/iamcal/emoji-data/master/img-apple-64/1f4f1.png">
    Point your phone's camera at the QR Code to connect automatically.
    </p>
    EOF
    } | pandoc --pdf-engine=xelatex -f html -t pdf -o "$out"
    echo "$out"
I used those GitHub URLs for the emojis because pandoc was being weird about the unicode versions.


Note to anyone blindly cutting and pasting this, the final EOF needs to be alone on the line with no indentation (VSCode did me a disservice and formatted it poorly which confused the hell out of shellcheck but left me learning something today, which was nice).


Since OP intended to learn a bunch of technologies while developing this project I'd be amused to see a version of this based on qrencode complied to WASM.


Why is this not a neural network?


And why no blockchain?


Mint a WiFi Login Card NFT


I wouldn’t ask if it wasn’t the top comment, on the current #1 front page story, but

Can someone please explain this command, and why it is presumably given as a criticism of this submission?


There is an inherent skepticism about typing your password into a web form even/especially if it says it is not sent to the server. My read of this comment was on the one hand telling security conscious people how to achieve the same goal in a way that does not leave the computer, and on the other hand putting a lower bound on the complexity of the value provided by the site.


https://github.com/fukuchi/libqrencode

This doesn't look "simpler" after a quick look, and it's a hard dependency of the GP solution.

(I completely agree on the local-only guarantee that this one provides, though)


I think the point of simplicity here is that you apt/yum/yay/whatever install qrencode and then go to town.

You're on your own machine, you know the exact spec used to generate the QR, and while you're at it, you can use the same tool to generate TOTP QR codes and WireGuard configurations and a bunch of other things like links to websites or automations for Tasker (et al).

The world is your oyster when you know what and how the "magic" works, and while you're at it, you aren't risking pasting your WiFi passwords into some random website.


I didnt read it as a criticism necessarily. Qrencode is just awesome. I like that someone made a UI for this though so non-ghost-in-the-shell folks can get down with this awesome use of QR code dopeness :^)


As other comments have pointed out, the tech stack used here is excessive for what it is trying to do. The author has said it was a project to learn some specific technologies. There is a lot of mirth for overcomplicated contraptions mucking up otherwise simple tasks (and rightfully so, IMO), hence the retort of a one-line console command.


It's not excessive. The linked post is way easier to use and doesn't require a terminal or installing packages manually. I wouldn't even know how to get the cli version to work on windows.

The only downside IMO is that you are entering your wifi details in to an untrusted website.


The command-line app is effectively eternal as long as it's mirrored and the runtime interface doesn't change. Can we count on this link to still be there when we need it?

Do you know how long most "Show HN" links still work after a year or two?


You can just fork/clone/whatever it, it's right there.


Ok, great. If it goes down now one has to host it or remember to start it via the command-line. So we're back to square one...


It's literally a webpage with some javascript, so if you save it along with the asset files, you can just open the page in browser from your filesystem, no need to specially host it or start anything.

But yes, I agree running a command like qrencode from terminal is easier in the long run.


Saving a webpage and expecting your browser to render this the same way in a few years is only possible if you are saving the browser version with it.

The command line tool will have a longer life


You could just use google to find the same thing in a few years. The project is so simple I could replicate it and have it hosted in a few hours.


"so simple" ... "in a few hours"

The project is so simple that it would be easier to rewrite it from scratch in that time frame. But the qrencode CLI allows to just avoid that.


Does that work for node.js apps?


Yes, but it depends if the node.js app has the option of generating a fully static site. But it will also need to generate relative links for the browser to be able to directlyy load the site


I don't think we should always see a reply as criticism. It makes the discussion unnecessarily contentious.

Even this reply - this is intended as conversation.


The site requires you to put in your WiFi Network and Password even though it did not have to. (However nothing is actually sent to the server)


> even though it did not have to

How could it work if it didn’t?


By generating the QR code locally via JS. You can check the source code https://github.com/bndw/wifi-card/blob/master/package.json#L...


I’m not sure what you think I was asking the previous commenter. This makes no sense as a reply.


I thought you were asking the parent how the QR generation worked, if it didn't send something to a server.


But... that's exactly what it does though?


A decade old SO adage comes o mind:

"This should be the accepted answer."


For WPA3

  WIFI:S:SSID;T:WPA3;P:PASSWORD;;


Can you elaborate? Why doesn't the traditional WPA1/WPA2 string work? What happens if a non-WPA3 client scans this new one?


Late reply, but when I was setting up WPA3 a few months ago I used Android 11 as a reference and that is what it spits out from the Settings share screen. Without it iirc, it would search and search and never connect.


For users of NetworkManager:

  nmcli device wifi show-password


Wow thanks. I just learned something new.

This is now my favourite way to grab the WiFi password.


+1

Why has it never occurred to me that I might be able to use a QR code? I always do `sudo cat /etc/NetworkManager/system-connections/TheSSID.nmconnection | grep psk`, type in my root password and then re-type the passphrase manually on my phone. The amount of time this is going to save me…


I was always aware my phone has an option to scan a QR to connect to WiFi, but I never thought to look up the QR spec for it. I had no idea nmcli had this functionality either, though I have used qrencode a lot for TOTP and WireGuard.


    Write-Host "?"


Did you type this in from memory?!


There is no real specification. This is the best source[1], which documents QR standards.

>There are some standards -- de facto and otherwise -- already in use. This wiki attempts to catalog some possible standards for encoding various types of information, and suggest a standard action associated to them.

[1]: https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-n...


Damn, that's saddening, but also answers a question I had about what the escape character is for a password containing `;` -- I guess there's no specification to tell me :-(

OTOH, I guess a "standard" is whatever the common implementations accept anyway, so if one could dig up the source to the WiFi QR scanner in source.android.com that's the 2nd best thing


No specification, but the linked website mentions that they “propose a syntax like "MECARD" for specifying wi-fi configuration” and then later:

> Special characters \, ;, ,, " and : should be escaped with a backslash (\) as in MECARD encoding.


Not OP, but I found that string from viewing the source code for Card.js in the sources tab.


In fairness, the string doesn't seem insaneo: T:=Type S:=SSID P:=Password then only the leading and trailing chars need to be "remembered", plus whatever the escape character is for that password string (or maybe even the SSID -- I'm not super clear on what characters can be in an SSID)


> I'm not super clear on what characters can be in an SSID)

I hear “%s%s%s%s%p” is the preferred SSID these days…



[flagged]


And access to Linux. Which most of non-tech people are not going to have.


Works on Android using Termux. libqrencode is a package in its default repo. From what I understand, Android is quite popular.


If the options for helping someone are sending them a URL or explaining how to install termux and then a new package and then running an obscure command in it, I know which option I would pick.


Thankfully, anyone on Android 10 and up already has sharing of wifi via we built in.

As should any of the new routers.


My new router came with the QR code stuck on. ios and apparently android have wifi sharing but its still going to be problem when an android user visits an ios user.


Fortunately, the two rarely comingle.


[flagged]


I disagree and I found both the command line and ui versions interesting, kudos to both OP and the CLI poster :)

As stupid as it sounds I didn’t realize there was a wifi scheme for a uri-like syntax on phones


I definitely found the qrencode command interesting, just not the reply to which I replied.


>zsh: command not found: qrencode


brew install qrencode && !!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: