I don't think this is the right place for that, but there are generally a bunch of libraries which will help you get this sorted out. If you tweet at me your tech stack and framework(s), I might be able to help you with more info. My details are in my bio.