Encryption, at least, is a purely defensive weapon. In the historical context of 2A, protecting yourself from your government would closely align with the original intent of militias protecting locals from a federal king.
Yeah. After an expensive legal defense, maybe with a bunch of expensive appeals, you'd be either wrong, poor, and in jail or right, poor, and not in jail.