I couldn't find the original contribution to add this to so am uploading here.
Use this contribution if you store credit card information in your database. This simple contribution allows you to wipe out all but the last four digits of the card number when you update an order. You can perform this wipe manually or choose to have it done automatically when the order is updated to a particular status (normally Delivered or Shipped). An example is included of how to set it up when you are using CVV (so you can wipe out the CVV as required when it is no longer needed) and credit card encryption.