It depends on what you need. In most cases the code on StackOverflow is not exactly what you need, so you need to understand it in order to adapt it. But if you're looking for a specific well-defined algorithm (MD5, say) then you can just copy & paste it.