Hey, there is no free lunch, so answer is those are not legal.
If you get code for free or with unbelievable discount, remember: codes are usually purchased with stolen credit card details and Spotify will lock those accounts and no way to re-activate those. Purchase Spotify only from official shops or Spotify.com site!
Also! Keep in mind: do not install any code generators as those may include virus, trojan or some piece of **bleep**ty malware.
So let me say that if you don't want malware to your PC or spam for life to your mail inbox, turn around from that code generator .zip package and find some money to purchase Spotify legally. Believe me. :)