You can't just throw stuff together
It's easy to forget mains electrical can kill you*.
If you are an electronics hobbyist, you should be working in low-voltage. The common, UL-listed "wall wart" power supply is your "get out of jail free" card, as the rules are very much relaxed for low voltage DC devices. This is precisely why near every consumer electronics device from a CPAP to an Internet router uses this technique.
In mains wiring, the wiring methods and other details are everything. We're not banging rocks together here, so don't you do it.
That plastic box is intended only for in-wall installation of "Romex" NM, UF etc. cable. The box does not have the proper strain relief for any other kind of cable, and certainly not for use outside a wall.
Credit to you for using proper cordage instead of Romex, which is not made for cordage, is too brittle and will fatigue crack.
Ground this thing
Any homebrew device should always be grounded. A side-effect of grounding is that the hot and neutral are now polarized, assuming we're in North America and other places with asymmetrical sockets. Now that you're polarized, switch the hot obviously.
Use 3-wire cordage -- unlike Romex, cordage counts the ground so it is called /3 (as in 16/3 for 16AWG cord). Hack up an extension cord if the cable itself is marked correctly as cordage (SJOOW or other legal markings as listed in NEC Article 400). Target sells an 8' black for under $5, or visit an electrical supply house**. You'll want round.
You can get inline switches for 3-wire (w/ground) cordage. You just have to look a little harder.
Since you are grounding, a metal switch enclosure now makes more sense. This will handle abuse much better. Also make a point to fit a switch cover plate to keep fingers, Mountain Dew and cat tongues away from the hot switch terminals.
Any homebrew like this should be protected by both GFCI (ground fault detection) and AFCI (arc-fault detection). GFCI detects current deviating from the normal "out the hot back the neutral" flow, and grounding helps by providing a safe third path. AFCI detects electrical arcing trying to start a fire. This would be in the circuit upstream of the device, commonly an AFCI/circuit breaker and GFCI/receptacle.
Neutral is not ground, and neutral should not be intentionally bridged to ground anywhere in any of your work. Doing so is a ground fault. Obviously that will trip GFCIs, as well as most AFCIs.
3-prong plugs have a side effect: They are polarized. That means you have a definite "Hot" and "neutral" wire. Put the switch on the hot wire obviously.
The safer way to do it illegally
The legal way would be a pre-made, 3-wire, listed inline switch whose labeling and instructions say to use it this way. But if you prefer illegal we can at least up the safety.
Instead of that plastic junker, get an aluminum 1-gang box with 2 threaded 1/2" (trade size) holes top and bottom, your strain reliefs screw into those.
Bring the cord into the electrical supply house (or buy it there) and get an appropriate compression strain relief to fit the cord and screws into the 1/2" trade size thread. It probably comes with a "nut" for going into steel boxes, ditch the nut.
Continue onto the appliance with /3 cordage and a strain relief there as well. Tying a knot in the cord doesn't cut it. (or to be more precise, does.)
At the machine's chassis, use the strain relief with the nut to enter a 1/2" trade-size knockout (otherwise known as a 13/16" hole).
Wiring wise, ground goes to chassis in all locations. The aluminum box has a hole pre-threaded #10-32 and everywhere sells little green #10-32 machine screws for grounding. Any 10-32 will do. Crimp terminals are OK here.
* It can also burn your house, and a fire inspector will find the cause. Your fire insurance will not pay, leaving you fiscally liable. If someone is injured, civil actions; if killed, criminal charges. Debt from an illegal act can't be cleared in bankruptcy.
** Home Depot is not an electrical supply house. Walmart is not an electrical supply house. Most are local family businesses, but Greybar and City Electric are semi-national chains.