Like most things in Iran, the legal system is based on Islamic principles. The system, however, is not the strictest interpretation of Sharia law. Most of the same activities that are illegal in your country are illegal in Iran, but the penalties can be much harsher. For most minor crimes, foreigners will probably be deported, though this is not an absolute. A few years ago, a German businessman was sentenced to death for having sex with an unmarried Muslim woman, though he was eventually released after serving about two years in jail. The penalties for drug or alcohol use and smuggling are harsh. Carrying the smallest amount of hashish can result in a minimum six-month jail sentence; don't expect assistance from your embassy or a comfortable cell. Trafficking heroin or opium carries the death penalty.
There are two 'crimes' that foreigners may not be aware of. Homosexual activity is illegal and has resulted in the death penalty for some Iranians. Deliberate refusal to wear correct hejab (the Islamic dress code for women) can also result in a public flogging (although a foreigner will probably be deported).