Digital Millennium Copyright Act (DMCA) is a 1998 United States copyright law that implements two 1996 treaties of the World Intellectual Property Organization (WIPO). ... It also criminalizes the act of circumventing an access control, whether or not there is actual infringement of copyright itself
So, yes software code can be illegal.
If a bunch of 1's an 0's represents banned content (child porn, plans for a nuclear bomb, etc) then it can be illegal.