It will never be completely safe, especially with physical access to the machines, but you can make it difficult.
Use 3DES to encrypt the database fields that you want to protect. Please note that you do not need to encrypt each field, and you should not. (both for speed and because if you lose the key, you will at least understand what you need to do)
Do not store the key on the database server. If necessary, save it to a disk other than a database or web application.
Keep a backup copy of the key on a flash drive or something like that. Do not miss this step.
Divide the key file into several different files scattered in different folders and different drives. Do not use names indicating the purpose of the files. Keep the places in the registry.
Use the code to read the registry, extract the key fragments and collect them. Write this code yourself and do not use a name that indicates the purpose of the program.
source share