I had recently taken the hard drive out of my computer so that I could install a bigger one. But when I reconnected it to the computer, all the files on the E:\ partition and some of the files on the C:\ partition had strange names like TTv5yV5354$YVC5Wy on them. I did on one occasion move an electromagnet near the drive. Could that have caused this? Please help me, some of those files were valuable.
Here is the check list on how to recover data from a harddisk:
How badly do you need your data?
Go to a Data Recovery Company, if possible one which has a good reputation and does not brag itself with a fast and cheap recovery.
Not very, but would be nice to have again...
If the filesystems are still intact you can try to run appropriate check tools (fsck.*) and recovery tools.
If the harddisk is not even recognized you could try to get the same (!!!) model again and swap out the controller, that at least would rule out that possibility (of a faulty controller, that is).
Not sure if I need it at all...
Well, check it, repair it, read from it, write to it, copy stuff, place it on the heater, in the freezer, tip it, swing it, punch it...might work at some point again.
My drive was encrypted...
...and that stinky Data Recovery Company will never get my key!
That's great...for you, that is. Encrypted data is not or hardly distinguishable from random data. So even if the company is able to copy stuff off the harddisk, they won't be able to tell you how successful that was until you're at home and try to decrypt whatever they got off the harddisk.
...and I guess I can trust that company.
That's great...also for you, because they might be able to help you in that case.
...and I've forgotten the key...how do I get my data?
Well...how do I put this? The whole point of encryption is that somebody without the key will not get your data...you don't have the key, you don't get the data!
What if all this does not work?
You do have a backup, right?
And in your special case?
I'd recommend a data recovery company. If the harddisk has been closed to a magnetic field, and the filesystem is still intact (read: it is recognized as filesystem), then there's a good possibility that random areas of the disk have been overwritten with random (and in this case it's really random) data. The files and directories you still see good be anything.
Though, as you describe it, there might a good chance that data is still intact and only the file table has been damaged (that's a long shot by the way). Copying the disk with ddrescue and trying different recovery strategies on that copy might return the original data. If you're lucky you get the data back without the correct filenames and you'll have to sort it by hand...if you're unlucky you get junk back.
Anyway, I'd recommend a professional in this case.