A man has been sentenced to 20 months in prison after he was found with 28 bags of cocaine hidden in his sock during a police stop.