So correct me of I'm wrong. When you're "mining" you're computer is essentially guessing a random number, encrypting it, and comparing it to the already encrypted block.
That doesn't sound quite right ... I'll try to explain it. Remember, this is only
In order to successfully get 50 BTC, or whatever the current reward is, a Bitcoin client must add a block to the current block chain, and show the new block to everyone else. So the first thing the client program does is put together a small data structure that is the block header. This block header contains a copy of the last block's hash, which is why blocks form a chain, and a bunch of other data.
Before this potential block will be considered valid by others, the SHA-256 hash of the block header (actually, only a portion of the header) must be less than or equal to a 256-bit Target. The Target is determined by the current Difficulty.
Obviously, most of the time when the client puts together the block header the hash will not
be less than the Target. To "mine" a block the client, or dedicated mining program, must manipulate various fields in the block header in an attempt to find values that make the hash less than the Target. Since SHA-256 generates pseudo-random numbers, and isn't feasibly reversible or predictable, this basically just amounts to brute-forcing.
There is one field in particular, called the Nonce. It's a 32-bit value that miners increment from 0 to 2^32, running the SHA-256 hash each time to check if they've found a Nonce that makes the block header valid.
Once a block header has been found that meets the Target requirement, the bitcoin client can add confirmed transactions to the block and then share it with the rest of the world. Other bitcoin clients can run the SHA-256 on the block header to confirm that this new block is indeed valid.
There's just one more thing. The bitcoin client usually does all the work of putting together the block header and such. Dedicated mining programs can communicate over JSON-RPC with a bitcoin client to ask for "work". The bitcoin client returns only the portion of the block header that actually needs to be worked on, and the miner is only
responsible for searching all 2^32 values of the 32-bit Nonce. If it finds a valid Nonce, it can report its findings back to Bitcoin which will finish up constructing the block and submit it to the world. If the miner doesn't find a valid Nonce, it can make another "getwork" request of the bitcoin client, which will change a few fields in the block header and then give new work to the miner.