Silencers are more properly called sound moderators or suppressors (since nothing "silences" a weapon completely) and are widely used to reduce noise levels from the discharge of firearms.
A sound moderator is essentially no more than a series of baffles coupled to an expansion chamber, contained within a tubular attachment which screws on to the end of the firearm's barrel.
The noise of the discharge of most firearms is made up of two components. The first comes from the rapid expansion of propellant gases as they leave the muzzle. The second is the supersonic crack of the bullet. It is not possible to reduce the sound level of a supersonic bullet, but a sound moderator fitted to such a rifle will have some significant effect in reducing the noise signature because it controls the rate of expansion of the propelling gases.
For a sound moderator to be really effective, it must be used with ammunition whose projectiles travel at less than the speed of sound. In such cases, the noise of the discharge is greatly reduced and may not even be recognizable as a gun.
The first successful silencers were patented in 1910 by the American inventor Hiram P. Maxim (son of Hiram S. Maxim of Maxim machine-gun fame). His devices were of the baffle type, which is still in common use today. A baffle silencer typically consists of a metal cylinder, usually divided into two sections, which is fixed to the muzzle of the firearm.
The first section, which is typically about a third of the silencer's length, contains an "expansion chamber" into which the hot gases that follow the bullet out of the muzzle can expand to dissipate some of their energy. The expansion chamber may contain a wire mesh cylinder, whose function is to break up the column of gas and to cool it by acting as a heat sink.
The second section consists of a series of metal baffles, with a central hole to allow the passage of the bullet. The function of the baffles is to progressively deflect and slow the flow of gas emerging from the expansion chamber, so that by the time the gases emerge from the silencer, their flow is cooler, at low velocity and silenced. A motorbike silencer works on exactly the same principle.
There are also variations on this theme: some designs consist entirely of baffles, while others are based entirely on one large expansion chamber.
In fact, the movie industry has offered some alternatives for a "home-made" silencer, some more plausible than others.
A plastic soft drinks bottle can be made into a fairly efficient silencer that will work for a limited number of shots before it breaks up.
Potatoes at the end of the barrel definitely don't work.
The pillow doesn't really help, either, though it does have the benefit of minimizing or negating blood splatter during the shooting.
A less common, type of silencer is the "wire mesh" design. These usually have the same expansion chamber as the baffle type, but the baffles are replaced by a column of knitted wire mesh with a central hole for the bullet. Here, the wire mesh acts to disrupt the column of gas as in the baffle design, while at the same time acting as a heat sink to cool the hot gas and hence quieten it. Criminals have been known to improvise this type of silencer, using wire wool or steel pan scourers to form the mesh.
The very latest innovation in muzzle-mounted silencers is the so-called "wet" silencer (or "wet can" in the US). These designs allow the use of water or a lubricating oil. On firing, the hot expanding gases are cooled, and therefore quieted, by the exchange of heat into the liquid. Wet silencers allow the designer to produce much smaller or quieter designs.
So, it is fair to say that Hollywood takes great artistic liberties with silencers. Most real designs are much larger than the cigar-tube sized ones typically shown on film and usually much less simple to fit and remove and more likely to produce a muffled crack, or to sound like a car door being slammed, instead of the "fart" seen and heard in movies.
And by the way, "silencers" don't work and the best suppressors do only half the job, so being a hitman must be more difficult than you thought.