Tham khảo tài liệu 'expert sql server 2008 development- p4', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 6 ENCRYPTION Hashing A hashing function allows you to perform a one-way encryption of any data with deterministic results. By deterministic I mean that a given input into the hashing function will always produce the same output. Hashing in itself is arguably not a true method of encryption because once a value has been hashed there is no way to reverse the process to obtain the original input. However hashing methods are often used in conjunction with encryption as will be demonstrated later in this chapter. SQL Server 2008 provides the HASHBYTES function which produces a binary hash of any supplied data using one of a number of standard hashing algorithms. For any given input x HASHBYTES x will always produce the same output y but there is no method provided to retrieve x from the resulting value y. Figure 6-3 illustrates the HaShbYtES function in action. HASHBYTES is useful in situations where you need to compare whether two secure values are the same but when you are not concerned with what the actual values are for example to verify that the password supplied by a user logging into an application matches the stored password for that user. In such cases instead of comparing the two values directly you can compare the hashes of each value if any two given values are equal then the hashes of those values produced using a given algorithm will also be the same. Although hash algorithms are deterministic so that a given input value will always generate the same hash it is theoretically possible that two different source inputs will share the same hash. Such occurrences known as hash collisions are relatively rare but important to bear in mind from a security point of view. In a totally secure environment you cannot be certain that simply because two hashes are equal the values that generated those hashes were the same. The HASHBYTES function supports the Message Digest MD algorithms MD2 MD4 MD5 and the Secure Hash Algorithm SHA algorithms SHA and SHA1. Of .