﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / EncryptByPassPhrase/DecryptByPassfrase, why don't this work? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 13:37:41 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: EncryptByPassPhrase/DecryptByPassfrase, why don't this work?</title><link>http://www.sqlservercentral.com/Forums/Topic1366346-1292-1.aspx</link><description>With blanks?SQL ignores trailing spaces when comparing strings. Just make sure that the char length is longer than the string you're converting.</description><pubDate>Mon, 01 Oct 2012 02:04:52 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: EncryptByPassPhrase/DecryptByPassfrase, why don't this work?</title><link>http://www.sqlservercentral.com/Forums/Topic1366346-1292-1.aspx</link><description>Thanks!did the trick even without lengt for char.I wonder a bit - 070564-2869  - has 11 characters, but should i use 'With blanks'?Best regardsEdvard Korsbæk</description><pubDate>Mon, 01 Oct 2012 01:57:08 GMT</pubDate><dc:creator>edvard 19773</dc:creator></item><item><title>RE: EncryptByPassPhrase/DecryptByPassfrase, why don't this work?</title><link>http://www.sqlservercentral.com/Forums/Topic1366346-1292-1.aspx</link><description>I think you've got that query the wrong way around. You're comparing the encrypted column with the results of the decryption function. You should be comparing the decrypted value with the results of the decryption function applied to the column.Also, you're not specifying a length for char, you should. do you know what the default is?Something roughly like this[code="sql"]select COUNT(*) from dbo.personal where  Convert(Char[&amp;lt;whatever the string length is&amp;gt;,DecryptByPassPhrase('[PASSPHRASE]',CPR_encrypted)) = '070564-2869'[/code]</description><pubDate>Mon, 01 Oct 2012 01:50:16 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>EncryptByPassPhrase/DecryptByPassfrase, why don't this work?</title><link>http://www.sqlservercentral.com/Forums/Topic1366346-1292-1.aspx</link><description>This query returns a lot of results:select Convert(Char,DecryptByPassPhrase('[PASSPHRASE]',cpr_encrypted)) from dbo.personal I have changed the actual passphrase to [PASSPHRASE] above.one of the results is:'070564-2869                   'Without the quotation marks, but there is a lot of blanks in it. the field is defined as cpr_encrypted varbinary(256)Then i use this to find it again:select COUNT(*) from dbo.personal where CPR_encrypted = Convert(Char,DecryptByPassPhrase('[PASSPHRASE]','070564-2869                   '))Which returns zero (nul NULL, zero)What am i doing wrong?Best regardsEdvard Korsbæk</description><pubDate>Mon, 01 Oct 2012 01:37:27 GMT</pubDate><dc:creator>edvard 19773</dc:creator></item></channel></rss>