From an employer's perspective:
If I'm hiring an engineer, I would look at more than just a few snippets of code. What interests me more is how the person is using the overall architecture of the application.
If I'm an ex-employer, I would not feel comfortable with our source code being shown around -- which could potentially reveal a vulnerability.
Your best bet would be to create a small dummy application and put it on GitHub.
That would actually be better for you as well, since in most cases people aren't happy with everything about a previous application they've worked on (especially if there were other engineers working on it with you).
Nishank Khanna has some really good points except for one: "a small dummy application". I would recommend you regularly contribute to open source projects on github as well as maintain at least one small open source project of your own. I am not directly in charge of hiring where I work, but I am almost always included in our panel interviews and I always check before hand if the candidate contributes to oss projects and I base most of my questions on what I found out from snooping on their github.
Speaking as a hiring manager bringing in source code that you don't own without an agreement from your former employer in-hand is a disqualifying event.
Here's why - Even if your'e trying to be careful with it you're not respecting your former employers ownership of the code it paid you to write. So my company can't trust you to respect our policies either. Plus how can I be sure that you actually wrote the code yourself and aren't passing off something a coworker wrote?
I say this from experience having interviewees bring in code (once the entire codebase!) from former employers and I'll give you the same advice I gave them which is similar to other answers here. If you want to have a code sample (and you should) the best thing to do is to go write an application that scratches an itch for you or contribute to an open source project you are interested in. I can be more confident that you actually wrote it and you might even earn a little income from your itch-scratching application.