If any person, knowing of the commission of an offense, take any money, or reward, or an engagement therefor, upon an agreement or undertaking, expressed or implied, to compound or conceal such offense, or not to prosecute therefor, or not to give evidence thereof, he shall, if such offense be a felony, be guilty of a misdemeanor, and, upon conviction, be confined in jail not more than one year and fined not exceeding $500; and if such offense be not a felony, unless it be punishable merely by a forfeiture to him he may be confined in jail not more than six months, and shall be fined not exceeding $100.