
First of all, Select the 'Pencil-Tool' and set the size down to 1 pixel. Then hold your shift key and create a line like above.

Then go to Filter >> Noise >> Add Noise and copy the settings above

Now with your line having the filter applied, Select the 'Selection Tool' and stretch the line as shown above. You should end up with something similar.

Now go to Adjustments >> Levels and Drag the white to the left, to remove the grey lines....

You should end up with a Barcode like above, just Black and White lines.

This is what I did to make it look real. Here you can download the PSD to check how it wsa done.