This is a congruent conflation of “tough cookie” and “a hard (or tough) nut to crack”, both describing difficult people to deal with. I suppose you can crack cookies, particularly if they are very stale. My mom would put a piece of bread in the cookie jar to avoid cracked cookies. A big thanks to Mary for blurting this one out, describing her very sassy cat. Apparently the cat is still a tough cookie to crack.