—Information accurate as of: build 904.83
A Door Key costs 25 Wood per key to make. It allows the bearer of the key to open, close, lock and unlock the Door. Each time a Lock is deployed on a door, it is assigned, by the game, a number between one and 100, which keys made from it will acquire; unless a Door Key used on it matches that number, it will not unlock the door. To create a key, the door must be unlocked; the player goes up to their Key Lock and presses the "E" key (by default) on the lock. While any key and 25 Wood is held in inventory, a duplicate key for it can be created; pressing E on the door will not create a key if one already exists. The Lock can be removed while it is unlocked, and deploying it again will reset the number, probably rendering existing keys unusable.
Door keys must be carefully safeguarded so other players cannot gain access to your building via the door. You should make two keys for your main door. The first key is kept inside the base in a safe location. This allows for new copies of your key to be made if the second key is permanently lost or you wish to make a copy for a friend. The second key is placed in a Small Stash or Wood Storage Box in a bush, crevasse, or other hidden area outside your building. Once you return to your building, check that you haven't been followed and retrieve your Door Key for re-entry. Be sure to create a Sleeping Bag inside your building before attempting this strategy in the case the second key is misplaced or destroyed.
Redeploying your Lock and making a new key for it will regain control of your Lock should another player acquire one of your keys, or can be used to gain control of another player's Lock if you acquire one of their keys. Deploying a Lock multiple times, and making a key from it each time, increases the chance that the multiple keys in inventory will match other player's Locks, and is the basic principle behind Key Raiding.
Key Raiding is not simply making an inventory of 100 keys and having a 100% chance of opening any lock. Almost all players upgrade to Code Locks when they can. There are not 100 inventory slots available. There is a random chance that a key created is a duplicate of another already made. Even with a hypothetical, impossible inventory of 100 keys, a handful of them would be duplicates, and there would be no keys to match a handful of potential locks. Lacking perfect probability knowledge and math, we can still see that the chances of getting duplicates becomes very high with this example: even assuming that 50 non-duplicated keys were created, every one of the keys thereafter would have a 50% chance or less of being a unique key, with the chance decreasing. So it seems likely to be somewhere near 50-60 unique keys created out of a crafting run of 100. Thus even with multiple runs to bring multiple full inventories of keys until all 100 have been tried, there would be only about 50% to 60% chance of opening any given door. Whether this is actually how randomness is represented in game is another matter.