What phone? This may matter because messages like that are manufacturer/model dependent.
But more importantly, flashing with unauthorised firmware does not generally lock a phone so that you can't use it - in fact I have never heard of any phone that does that. So the first thing I'd do is ignore that message and see whether I can access the data anyway. If the problem is actually an app and not a system feature then trying Safe Mode, as Milo suggests, would deal with that, but personally I'd just try booting it normally first and see whether there genuinely is a problem.
If you are actually prevented from accessing your data then please describe what happens when you try to boot it up (I'd not worry about a message that only appears on a charging screen).
(I am incidentally assuming that you have not tried to modify the phone in the past, and that this message is spurious. If you have ever modified it then if you cannot access your data please tell us what you did).