17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DecryptByKey<br />

Like its asymmetric and certificate based brethren, this one decrypts a chunk of data utilizing a key. What’s<br />

different is that this one not only expects a symmetric key (instead of the other types of key), but it also<br />

expects that key to already be “open” (using the OPEN SYMMETRIC KEY command). Other than that, it is<br />

fairly similar in use, with the encrypted data (either as a literal string or a string coercible variable) fed<br />

in as a parameter and, in this case, a hash key optionally accepted as an authenticator:<br />

DecryptByKey({‘’|},<br />

[, ‘’|])<br />

Note that if you provide an add authenticator value (in the form of an int), that value must match the value<br />

supplied when the string was encrypted, and you must also supply a hash value that matches the hash<br />

supplied at encryption time.<br />

DecryptByPassPhrase<br />

Like the name says, this one decrypts data that was encrypted not by a formal key, but by a passphrase.<br />

Other than accepting a passphrase parameter instead of assuming an open key, DecryptByPassPhrase<br />

works almost exactly like DecryptByKey:<br />

DecryptByPassPhrase({‘’|},<br />

{‘’|},<br />

[, ‘’|])<br />

As with DecryptByKey, if you provide an add authenticator value (in the form of an int), that value must<br />

match the value supplied when the string was encrypted, and you must also supply a hash value that<br />

matches the hash supplied at encryption time.<br />

EncryptByAsmKey<br />

Encrypts a chunk of data utilizing an asymmetric key. It requires the key (by ID) and the data to be<br />

encrypted (either as a literal string or a string coercible variable). The syntax is straightforward enough:<br />

EncryptByAsymKey(, {‘’|})<br />

Keep in mind that if a password was utilized when the asymmetric key was added to the database, the<br />

same password will be required to properly decrypt any data encrypted using that key.<br />

EncryptByCert<br />

Apendix A: System Functions<br />

This is basically the same as EncryptByAsmKey, except that it expects a certificate rather than an asymmetric<br />

key. Like EncryptByAsmKey, this one encrypts a chunk of data utilizing the provided key. It<br />

requires the certificate (by ID), the data to be encrypted (either as a literal string or a string coercible<br />

variable), and optionally, the password to be used to further encrypt the data. The syntax looks almost<br />

just like EncryptByAsymKey:<br />

EncryptByCert(, {‘’|}<br />

[, ‘’])<br />

Again, any password utilized when encrypting the data will be needed to properly decrypt it.<br />

601

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!