<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>encryption &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/encryption/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 26 Apr 2018 19:17:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server: Encrypt Column data using Symmetric Key Encryption</title>
		<link>https://www.dbrnd.com/2017/04/sql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 18 Apr 2017 16:16:55 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[AES]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Column encryption]]></category>
		<category><![CDATA[Data Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[SYMMETRIC KEY]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5041</guid>

					<description><![CDATA[The Database Security is a very common and one of the major aspects for DBA to keep data secure. If you don&#8217;t know about SQL Server TDE, please read below article which uses for data encryption in SQL Server. SQL Server: Transparent Data Encryption (TDE) to Encrypt a Database There are different ways to encrypt [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&amp;linkname=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&amp;linkname=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&amp;linkname=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&amp;linkname=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&amp;linkname=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&amp;linkname=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F04%2Fsql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes%2F&#038;title=SQL%20Server%3A%20Encrypt%20Column%20data%20using%20Symmetric%20Key%20Encryption" data-a2a-url="https://www.dbrnd.com/2017/04/sql-server-encrypt-column-data-using-symmetric-key-encryption-data-security-aes/" data-a2a-title="SQL Server: Encrypt Column data using Symmetric Key Encryption"></a></p><p>The Database Security is a very common and one of the major aspects for DBA to keep data secure.<br />
If you don&#8217;t know about SQL Server TDE, please read below article which uses for data encryption in SQL Server.</p>
<blockquote class="wp-embedded-content" data-secret="qNqZwgAndj"><p><a href="https://www.dbrnd.com/2016/05/sql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file/">SQL Server: Transparent Data Encryption (TDE) to Encrypt a Database</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/05/sql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file/embed/#?secret=qNqZwgAndj" data-secret="qNqZwgAndj" width="600" height="338" title="&#8220;SQL Server: Transparent Data Encryption (TDE) to Encrypt a Database&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>There are different ways to encrypt your data like TDE, data masking, symmetric key.</p>
<p>In this post, I am sharing a demonstration on how to encrypt your table column using Symmetric key encryption.<br />
For example, When you are storing customer&#8217;s credit card information, you must encrypt all cards related columns.</p>
<p><strong>Below is a full demonstration of this:</strong></p>
<p><strong>Create a table with sample data:</strong></p><pre class="crayon-plain-tag">CREATE TABLE dbo.tbl_CustomerCards
(
	CustID INT PRIMARY KEY
	,CustName VARCHAR(10)
	,CustCardNo CHAR(8)
)
GO
INSERT INTO dbo.tbl_CustomerCards VALUES
(1,'Anvesh','25-85-96'),(2,'Neevan','88-26-19')
,(3,'Roy','29-30-32'),(4,'Muskan','36-22-69')
,(5,'Martin','26-88-66'),(6,'Jenny','74-21-31')
GO</pre><p>
<strong>Create your master key and give password base on windows policy:</strong></p><pre class="crayon-plain-tag">CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Dbrnd888';
GO


--If your password does not match windows policy, you will get a below error.
Msg 15118, Level 16, State 1, Line 1
Password validation failed. The password does not meet Windows policy requirements because it is not complex enough.</pre><p>
<strong>Create a database certificate which is protected by database master key:</strong></p><pre class="crayon-plain-tag">CREATE CERTIFICATE dbrnd_certificate
WITH SUBJECT = 'dbrnd Data';
GO</pre><p>
<strong>Create a symmetric key which uses for encryption/decryption:</strong><br />
I used AES_256 algorithm.</p><pre class="crayon-plain-tag">CREATE SYMMETRIC KEY dbrnd_Symmetric_key
WITH ALGORITHM = AES_256 
ENCRYPTION BY CERTIFICATE dbrnd_certificate;
GO</pre><p>
<strong>Add one more column in a table:</strong></p><pre class="crayon-plain-tag">ALTER TABLE tbl_CustomerCards 
ADD CustCardNo_encrypt VARBINARY(MAX) 
GO</pre><p>
<strong>Open a symmetric key for further use:</strong></p><pre class="crayon-plain-tag">OPEN SYMMETRIC KEY dbrnd_Symmetric_key
DECRYPTION BY CERTIFICATE dbrnd_certificate;
GO</pre><p>
<strong>Update newly created column by generating encrypted data with use of old column:</strong></p><pre class="crayon-plain-tag">UPDATE tbl_CustomerCards
SET CustCardNo_encrypt = EncryptByKey (Key_GUID('dbrnd_Symmetric_key'),CustCardNo)
FROM tbl_CustomerCards
GO</pre><p>
<strong>Now, You can remove your old column:</strong></p><pre class="crayon-plain-tag">ALTER TABLE tbl_CustomerCards
DROP COLUMN CustCardNo;
GO</pre><p>
<strong>SELECT encrypted/decrypted card numbers:</strong></p><pre class="crayon-plain-tag">SELECT CustID, CustCardNo_encrypt AS 'Encrypted_CardNumber',
CONVERT(varchar, DecryptByKey(CustCardNo_encrypt)) AS 'Decrypted_CardNumber'
FROM dbo.tbl_CustomerCards;</pre><p>
<strong>Try to Insert few records with encrypted card number values:</strong></p><pre class="crayon-plain-tag">INSERT INTO dbo.tbl_CustomerCards VALUES
(7,'Meera',EncryptByKey( Key_GUID('dbrnd_Symmetric_key'), CONVERT(varchar,'66-52-36')))
,(8,'Laria',EncryptByKey( Key_GUID('dbrnd_Symmetric_key'), CONVERT(varchar,'99-36-23')))
GO</pre><p>
<strong>Once you complete with the use symmetric key, CLOSE it:</strong></p><pre class="crayon-plain-tag">CLOSE SYMMETRIC KEY dbrnd_Symmetric_key;
GO</pre><p>
<strong>The result:</strong></p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-5044 size-full" title="SQL Server Column Encrypted Result" src="https://www.dbrnd.com/wp-content/uploads/2017/04/SQLServerColumnEncryptedResult.png" alt="SQL Server Column Encrypted Result" width="554" height="179" srcset="https://www.dbrnd.com/wp-content/uploads/2017/04/SQLServerColumnEncryptedResult.png 554w, https://www.dbrnd.com/wp-content/uploads/2017/04/SQLServerColumnEncryptedResult-300x97.png 300w, https://www.dbrnd.com/wp-content/uploads/2017/04/SQLServerColumnEncryptedResult-150x48.png 150w" sizes="(max-width: 554px) 100vw, 554px" /></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Database Security Interview Questions and Answers  (Day-1)</title>
		<link>https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/</link>
					<comments>https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 18 Jul 2016 19:28:52 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Data Masking]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[orphaned user]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[secure socket layer]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Injection]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3364</guid>

					<description><![CDATA[What do you mean by Database Security? Database security refers to the collective measures used to protect and secure a database or database management software from illegitimate use and malicious threats and attacks. It is a broad term that includes a multitude of processes, tools and methodologies that ensure security within a database environment. What [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&amp;linkname=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fsql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1%2F&#038;title=SQL%20Server%3A%20Database%20Security%20Interview%20Questions%20and%20Answers%20%20%28Day-1%29" data-a2a-url="https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/" data-a2a-title="SQL Server: Database Security Interview Questions and Answers  (Day-1)"></a></p><p><strong>What do you mean by Database Security?</strong></p>
<blockquote><p>Database security refers to the collective measures used to protect and secure a database or database management software from illegitimate use and malicious threats and attacks. It is a broad term that includes a multitude of processes, tools and methodologies that ensure security within a database environment.</p></blockquote>
<p><strong>What is Data Masking?</strong></p>
<blockquote class="wp-embedded-content" data-secret="JnDNNa5P6s"><p><a href="https://www.dbrnd.com/2015/11/database-theory-what-is-a-data-masking-2/">Database Theory: What is a Data Masking ?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/11/database-theory-what-is-a-data-masking-2/embed/#?secret=JnDNNa5P6s" data-secret="JnDNNa5P6s" width="600" height="338" title="&#8220;Database Theory: What is a Data Masking ?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is Data Theft?</strong></p>
<blockquote><p>Data theft is the act of stealing computer-based information from an unknowing victim with the intent of compromising privacy or obtaining confidential information. Data theft is increasingly a problem for individual computer users, as well as big corporate firms.</p>
<p>Data must be stored and transmitted securely, so that information such as credit card numbers cannot be stolen. Over the Internet and Wide Area Network (WAN) environments, both public carriers and private network owners often route portions of their network through insecure landlines, extremely vulnerable microwave and satellite links, or a number of servers.</p></blockquote>
<p><strong>What are the different types of Security levels?</strong></p>
<ul>
<li>Physical</li>
<li>Human</li>
<li>Operating System</li>
<li>Network</li>
<li>Database System</li>
</ul>
<p><strong>What does Database Encryption and Decryption mean?</strong></p>
<blockquote><p>Database encryption is the process of converting data, within a database, in plain text format into a meaningless cipher text by means of a suitable algorithm.</p>
<p>Database decryption is converting the meaningless cipher text into the original information using keys generated by the encryption algorithms.</p>
<p>Database encryption can be provided at the file or column level.</p></blockquote>
<p><strong>What is SQL injection?</strong></p>
<blockquote><p>SQL injection is an attack by malicious users in which malicious code can be inserted into strings that can be passed to an instance of SQL server for parsing and execution. All statements have to checked for vulnerabilities as it executes all syntactically valid queries that it receives.</p>
<p>Even parameters can be manipulated by the skilled and experienced attackers.</p></blockquote>
<p><strong>What are the methods used to protect against SQL injection attack?</strong></p>
<p>Following are the methods used to protect against SQL injection attack:</p>
<ul>
<li>Use Parameters for Stored Procedures</li>
<li>Filtering input parameters</li>
<li>Use Parameter collection with Dynamic SQL</li>
<li>In like clause, user escape characters</li>
</ul>
<p><strong>How can SQL Server instances be hidden?</strong></p>
<blockquote><p>To hide a SQL Server instance, we need to make a change in SQL Server Configuration Manager.</p>
<p>To do this launch SQL Server Configuration Manager and do the following:</p>
<p>select the instance of SQL Server, right click and select Properties. After selecting properties you will just set Hide Instance to &#8220;Yes&#8221; and click OK or Apply.</p>
<p>After the change is made, you need to restart the instance of SQL Server to not expose the name of the instance.</p></blockquote>
<p><strong>What are Orphaned Users?</strong></p>
<p>A database user for which the corresponding SQL Server login is undefined or is incorrectly defined on a server instance cannot log in to the instance. Such a user is said to be an orphaned user of the database on that server instance.</p>
<ul>
<li>A database user can become orphaned if the corresponding SQL Server login is dropped.</li>
<li>A database user can become orphaned after a database is restored or attached to a different instance of SQL Server.</li>
<li>Orphaning can happen if the database user is mapped to a SID that is not present in the new server instance.</li>
</ul>
<p><strong>Would you please describe any five server role with its permission?</strong></p>
<ul>
<li>bulkadmin: Granted &#8211; ADMINISTER BULK OPERATIONS</li>
<li>dbcreator: Granted &#8211; CREATE ANY DATABASE</li>
<li>diskadmin: Granted &#8211; ALTER RESOURCES</li>
<li>processadmin: Granted &#8211; ALTER ANY CONNECTION, ALTER SERVER STATE</li>
<li>securityadmin: Granted &#8211; ALTER ANY LOGIN</li>
<li>serveradmin: Granted &#8211; ALTER ANY ENDPOINT, ALTER RESOURCES, ALTER SERVER STATE, ALTER SETTINGS, SHUTDOWN, VIEW SERVER STATE</li>
<li>setupadmin: Granted &#8211; ALTER ANY LINKED SERVER</li>
<li>sysadmin: Granted with GRANT option &#8211; CONTROL SERVER</li>
</ul>
<p><strong>Which authentication mode is more secured?</strong></p>
<blockquote><p>Windows authentication is definitely more secure as it’s controlled and authenticated by Active Directory policies.</p></blockquote>
<p><strong>What is a Symmetric key in Data encryption process?</strong></p>
<blockquote><p>In Symmetric cryptography system, the sender and the receiver of a message share a single, common key that is used to encrypt and decrypt the message. This is relatively easy to implement, and both the sender and the receiver can encrypt or decrypt the messages.</p></blockquote>
<p><strong>What is a Asymmetric key in Data encryption process?</strong></p>
<blockquote><p>Asymmetric cryptography, also known as Public-key cryptography, is a system in which the sender and the receiver of a message have a pair of cryptographic keys – a public key and a private key – to encrypt and decrypt the message. This is a relatively complex system where the sender can use his key to encrypt the message but he cannot decrypt it. The receiver, on the other hand, can use his key to decrypt the message but he cannot encrypt it.</p></blockquote>
<p><strong>What Secure Socket Layer (SSL) with SQL Server and can we enable it?</strong></p>
<blockquote><p>Yes: We can enable SSL with SQL Server</p>
<p>Microsoft SQL Server can use Secure Sockets Layer (SSL) to encrypt data that is transmitted across a network between an instance of SQL Server and a client application. Enabling SSL encryption increases the security of data transmitted across networks between instances of SQL Server and applications.</p></blockquote>
<p><strong>What are basic steps to configure SSL for SQL Server?</strong></p>
<blockquote><p>Install a certificate in the Windows certificate store of the server computer.</p>
<p>Click Start, in the Microsoft SQL Server program group, point to Configuration Tools, and thenclick SQL Server Configuration Manager.</p>
<p>Expand SQL Server Network Configuration, right-click the protocols for the server you want, and then click Properties.</p>
<p>On the Certificate tab, configure the Database Engine to use the certificate.</p>
<p>On the Flags tab, view or specify the protocol encryption option. The login packet will always be encrypted.</p></blockquote>
<p><strong>What are the built-In Schemas?</strong></p>
<ul>
<li>dbo</li>
<li>guest</li>
<li>sys</li>
<li>INFORMATION_SCHEMA</li>
</ul>
<p><strong>Are you agree with User-Schema Separation in SQL Server?</strong></p>
<blockquote><p>Yes: User-schema separation allows for more flexibility in managing database object permissions. A schema is a named container for database objects, which allows you to group objects into separate namespaces.</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/07/sql-server-database-security-interview-questions-and-answers-data-mask-encryption-decrption-ssl-orphand-user-sql-injection-day-1/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-15)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 26 Jun 2016 19:58:39 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[contains]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[freetext]]></category>
		<category><![CDATA[Full text searching]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Universally Unique Identifier]]></category>
		<category><![CDATA[UUID Data type]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3082</guid>

					<description><![CDATA[What do you know about the Universally Unique Identifier &#8211; UUID data type? Database Theory: The truth about Universally Unique Identifier &#8211; UUID When we are declaring a variable using SET or SELECT, What is the performance different between SET and SELECT? SQL Server: Truth about assigning variables using SET versus SELECT What is the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-15%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-uuid-data-type-encryption-full-text-search-day-15/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-15)"></a></p><p><strong>What do you know about the Universally Unique Identifier &#8211; UUID data type?</strong></p>
<blockquote class="wp-embedded-content" data-secret="SEzTGAfIgs"><p><a href="https://www.dbrnd.com/2016/03/database-theory-the-truth-about-universally-unique-identifier-uuid/">Database Theory: The truth about Universally Unique Identifier &#8211; UUID</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/database-theory-the-truth-about-universally-unique-identifier-uuid/embed/#?secret=SEzTGAfIgs" data-secret="SEzTGAfIgs" width="600" height="338" title="&#8220;Database Theory: The truth about Universally Unique Identifier &#8211; UUID&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>When we are declaring a variable using SET or SELECT, What is the performance different between SET and SELECT?</strong></p>
<blockquote class="wp-embedded-content" data-secret="LWlmYmIfBE"><p><a href="https://www.dbrnd.com/2016/03/sql-server-truth-about-assigning-variables-using-set-versus-select/">SQL Server: Truth about assigning variables using SET versus SELECT</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/03/sql-server-truth-about-assigning-variables-using-set-versus-select/embed/#?secret=LWlmYmIfBE" data-secret="LWlmYmIfBE" width="600" height="338" title="&#8220;SQL Server: Truth about assigning variables using SET versus SELECT&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the purpose of OPENXML clause SQL server stored procedure?</strong></p>
<blockquote><p>OPENXML parses the XML data in SQL Server in an efficient manner. It’s primary ability is to insert XML data to the RDB. It is also possible to query the data by using OpenXML. The path of the XML element needs to be specified by using ‘xpath’.</p></blockquote>
<p><strong>What is the use of @@CPU_BUSY statement?</strong></p>
<blockquote><p>It returns the time that SQL Server has spent working since it was last started.</p></blockquote>
<p><strong>Explain the use of keyword WITH ENCRYPTION. Create a Store Procedure with Encryption.</strong></p>
<blockquote><p>WITH ENCRYPTION indicates that SQL Server will convert the original text of CREATE PROCEDURE statement to an encrypted format. Users that do not have no access to system tables or database files cannot retrieve the encrypted text. However, the text will be available to privileged users.</p></blockquote>
<p><strong>If you need to script a table with data, how will you do that?</strong></p>
<blockquote><p>One way to achieve this by using  Generate Script Task in SSMS.</p>
<p>Right click on database and then go to Tasks and then go to Generate Scripts.</p></blockquote>
<p><strong>I have two tables with the same columns and data types. If I need toget distinct records from both of tables how can I do that?</strong></p>
<blockquote><p>We can use the UNION operators.</p></blockquote>
<p><strong>Can we send emails in HTML Format from SQL Server, How will you do that?</strong></p>
<blockquote><p>We can send email from SQL Server in HTML format by using dbo.sp_send_dbmail stored procedure. To send email in HTML format, we have to build the body of email with HTML Tags. The below code can be used to send basis HTML formatted email. If you want to loop through some results of table and send in HTML formatted email.</p></blockquote>
<p><strong>Can we create triggers on temp table?</strong></p>
<blockquote><p>No: we cannot create a trigger on temp table.</p></blockquote>
<p><strong>How would you get the size of a SQL Server Table?</strong></p>
<blockquote><p>EXEC sp_spaceused &#8216;TableName&#8217;</p></blockquote>
<p><strong>How would you determine if the expression is Numeric?</strong></p>
<blockquote><p><strong>ISNUMERIC( ):</strong> function is provided to us in SQL Server to check if the expression is valid numeric type or not. As per Microsoft it should work with Integers and Decimal data types and if data is valid integer or decimal, ISNumeric() should return us 1 else 0.</p>
<p><strong>Try_Convert( ):</strong> In SQL Server 2012. Microsoft introduced new function call Try_Convert( ). You can use try_convert function to convert to required data type and if it is not able to convert then it will return Null as output.</p></blockquote>
<p><strong>Which function is used to convert the integer value into spaces?</strong></p>
<blockquote><p>The SPACE function converts the specified integer value into spaces.</p><pre class="crayon-plain-tag">SELECT SPACE(8);</pre><p>
</p></blockquote>
<p><strong>What is constant folding?</strong></p>
<p><strong>SQL Server evaluates some constant expression early to improve the query performance. This is called constant folding.</strong></p>
<p><strong>What is a full text search in SQL Server?</strong></p>
<blockquote><p>Full text indexing is a great feature that solves a database problem, the searching of textual data columns for specific words and phrases in SQL Server databases.</p>
<p>Full Text Index can be used to search words, phrases and multiple forms of a word or phrase using FREETEXT () and CANTAINS () with “and” or “or” operators.</p></blockquote>
<p><strong>Can you execute full-text queries on a table without full-text index on that column?</strong></p>
<blockquote><p><strong>No: </strong>Before you can run full-text queries on a table, the database administrator must create a full-text index on the table. The full-text index includes one or more character-based columns in the table. These columns can have any of the following data types: char, varchar, nchar, nvarchar, text, ntext, image, xml, or varbinary(max) and FILESTREAM.</p></blockquote>
<p><strong>Are Full-text queries are case-sensitive?</strong></p>
<blockquote><p>Full-text queries are not case-sensitive. For example, searching for &#8220;DBRND&#8221; or &#8220;dbrnd&#8221; returns the same results.</p></blockquote>
<p><strong>What is the difference between LIKE and FULL-Text Search?</strong></p>
<blockquote><p>In contrast to full-text search, the LIKETransact-SQL predicate works on character patterns only. Also, you cannot use the LIKE predicate to query formatted binary data. Furthermore, a LIKE query against a large amount of unstructured text data is much slower than an equivalent full-text query against the same data.</p>
<p>A LIKE query against millions of rows of text data can take minutes to return; whereas a full-text query can take only seconds or less against the same data, depending on the number of rows that are returned.</p></blockquote>
<p><strong>What is a Full-Text Engine?</strong></p>
<blockquote><p>The Full-Text Engine in SQL Server is fully integrated with the query processor. The Full-Text Engine compiles and executes full-text queries. As part of query execution, the Full-Text Engine might receive input from the thesaurus and stoplist.</p></blockquote>
<p><strong>What is the internal process of Full-Text Querying?</strong></p>
<ul>
<li>The query processor passes the full-text portions of a query to the Full-Text Engine for processing. The Full-Text Engine performs word breaking and, optionally, thesaurus expansions, stemming, and stopword (noise-word) processing.</li>
<li>Then the full-text portions of the query are represented in the form of SQL operators, primarily as streaming table-valued functions (STVFs).</li>
<li>During query execution, these STVFs access the inverted index to retrieve the correct results. The results are either returned to the client at this point, or they are further processed before being returned to the client.</li>
</ul>
<p><strong>What is CONTAINS and FREETEXT of Full-Text predicates?</strong></p>
<blockquote><p>The CONTAINS and FREETEXT predicates return a TRUE or FALSE value. They can be used only to specify selection criteria for determining whether a given row matches the full-text query. Matching rows are returned in the result set. CONTAINS and FREETEXT are specified in the WHERE or HAVING clause of a SELECT statement. They can be combined with any of the other Transact-SQL predicates, such as LIKE and BETWEEN.</p>
<p>When using CONTAINS or FREETEXT, you can specify either a single column, a list of columns, or all columns in the table to be searched.</p></blockquote>
<p><strong>What it is not recommended to name the user defined Stored Procedures with sp_?</strong></p>
<blockquote><p>They are system defined and mostly resides under the master database so if we write a user defined stored procedure by the name sp_ the query engine will first search the Stored Procedure in the master database and if not found then it will search in the current session database.</p>
<p>This brings unnecessary round trip and reduce the overall performance of user defined stored procedures.</p></blockquote>
<p><strong>Can we use the PRINT statement in SQL Server Function?</strong></p>
<blockquote><p>No: We cannot use it.</p></blockquote>
<p><strong>If you are working on a SQL database and if suddenly a developer changes the code and your queries results start giving errors, how will you check using a T-SQL query (on system tables) that what has changed in the database.</strong><br />
<pre class="crayon-plain-tag">select o.name, o.object_id, o.modify_date, c.text
from sys.objects o
join sys.syscomments c
on o.object_id = c.id</pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQL Server: Transparent Data Encryption (TDE) to Encrypt a Database</title>
		<link>https://www.dbrnd.com/2016/05/sql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file/</link>
					<comments>https://www.dbrnd.com/2016/05/sql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 14 May 2016 18:34:42 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TDE]]></category>
		<category><![CDATA[Transparent Data Encryption]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2800</guid>

					<description><![CDATA[SQL Server 2008 introduced Transparent Data Encryption (TDE) technique to encrypt the different database files like data file, log file and backup file. As a Database Professionals, we are also responsible for all kinds of data and database security. You can find an N number of similar TDE theory over the internet, but still, I [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&amp;linkname=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&amp;linkname=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&amp;linkname=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&amp;linkname=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&amp;linkname=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&amp;linkname=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F05%2Fsql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file%2F&#038;title=SQL%20Server%3A%20Transparent%20Data%20Encryption%20%28TDE%29%20to%20Encrypt%20a%20Database" data-a2a-url="https://www.dbrnd.com/2016/05/sql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file/" data-a2a-title="SQL Server: Transparent Data Encryption (TDE) to Encrypt a Database"></a></p><p><a href="https://www.dbrnd.com/wp-content/uploads/2016/05/DataEncryption.jpg" rel="attachment wp-att-2804"><img loading="lazy" decoding="async" class="alignleft wp-image-2804 size-medium" title="SQL Server Data Encryption TDE" src="https://www.dbrnd.com/wp-content/uploads/2016/05/DataEncryption-300x225.jpg" alt="SQL Server Data Encryption TDE" width="300" height="225" srcset="https://www.dbrnd.com/wp-content/uploads/2016/05/DataEncryption-300x225.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/05/DataEncryption-150x113.jpg 150w, https://www.dbrnd.com/wp-content/uploads/2016/05/DataEncryption.jpg 600w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><em>SQL Server 2008 introduced Transparent Data Encryption (TDE) technique to encrypt the different database files like data file, log file and backup file.</em></p>
<p>As a Database Professionals, we are also responsible for all kinds of data and database security.</p>
<p>You can find an N number of similar TDE theory over the internet, but still, I would like to write an underlying note about what is TDE and why it is important.</p>
<blockquote><p>Any underlying encryption algorithm brings your data into a state that cannot be interpreted by anyone without applying a decryption key, password or certificates.</p>
<p>As a DBA, we have to also maintain the decryption key, password and certificates information backup because once we lost this information, we cannot decrypt the encrypted data or database.</p></blockquote>
<blockquote><p>TDE uses for bulk encryption at the different type of database files.<br />
You can enable TDE at the database level, and once we enabled, it encrypts all data into the pages before it writes to the disk and it decrypts when reading from the disk.</p></blockquote>
<blockquote><p>Once you enable TDE on a database, you do not require any other application code to manage encryption and decryption of the data so that you can use this feature without changing a single line of application code.</p></blockquote>
<blockquote><p>TDE uses the AES and 3DES encryption algorithms, and the encryption and decryption operations are run on background threads by SQL Server and database backup also encrypted by TDE.</p></blockquote>
<blockquote><p>TDE only encrypts the data before writing to the disk, so there is also another different state where TDE is not applying encryption.</p>
<p>When you are sending and transferring your data between SQL Server and other application, the TDE doesn&#8217;t apply any encryption.</p>
<p>Before writing to the disk, data is coming from buffer pool and into this buffer pool area data is available in the plain text format, so TDE doesn&#8217;t apply any encryption in this buffer pool.</p></blockquote>
<blockquote><p>The performance overhead is involved in using TDE. The encryption and decryption process does require additional CPU cycles. The cost for using TDE ranges from about 3 percent to 30 percent, depending on the type of workload.</p></blockquote>
<blockquote><p>SQL Server instances with low I/O and low CPU usage will have the least performance impact. Servers with high CPU usage will have the most performance impact.</p></blockquote>
<p>In the next post, You can find require <a href="https://www.dbrnd.com/2016/05/sql-server-how-to-enable-transparent-data-encryption-tde-create-master-key-certificate-on-a-database/" target="_blank"><strong>T-SQL scripts and steps to enable TDE</strong></a> on the SQL Server Database.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/05/sql-server-transparent-data-encryption-tde-to-encrypt-a-database-data-log-backup-file/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL: Best way for Password Encryption using pgcrypto&#8217;s Cryptographic functions</title>
		<link>https://www.dbrnd.com/2016/03/postgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions/</link>
					<comments>https://www.dbrnd.com/2016/03/postgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 01 Mar 2016 20:33:12 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[crypt()]]></category>
		<category><![CDATA[cryptography function]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[digest()]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[gen_salt()]]></category>
		<category><![CDATA[hmac()]]></category>
		<category><![CDATA[pgcrypto]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=1851</guid>

					<description><![CDATA[This is going to be one of the most important article for the PostgreSQL community because I am going to share, what should be our best practice to store encrypted passwords into PostgreSQL Database Server. I am sharing some of the important pgcrypto&#8217;s cryptographic functions for PostgreSQL password encryption. Generally, people are using MD5 and [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&amp;linkname=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&amp;linkname=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&amp;linkname=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&amp;linkname=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&amp;linkname=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&amp;linkname=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F03%2Fpostgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions%2F&#038;title=PostgreSQL%3A%20Best%20way%20for%20Password%20Encryption%20using%20pgcrypto%E2%80%99s%20Cryptographic%20functions" data-a2a-url="https://www.dbrnd.com/2016/03/postgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions/" data-a2a-title="PostgreSQL: Best way for Password Encryption using pgcrypto’s Cryptographic functions"></a></p><p>This is going to be one of the most important article for the PostgreSQL community because I am going to share, what should be our best practice to store encrypted passwords into PostgreSQL Database Server.</p>
<p>I am sharing some of the important pgcrypto&#8217;s cryptographic functions for PostgreSQL password encryption.</p>
<blockquote><p>Generally, people are using MD5 and SHA algorithm for password encryption, but both are easy to break and vulnerable, so we should not use this in our general practice.</p></blockquote>
<p>The PostgreSQL provides pgcrypto module or extension with the set of cryptography functions.</p>
<p><strong>First, We need to install the pgcrypto extension in PostgreSQL. </strong></p><pre class="crayon-plain-tag">CREATE EXTENSION pgcrypto;</pre><p>
<strong>Below is a list of hashing algorithm along with its require bit size.</strong></p>
<ul>
<li>MD5 = 128-bit hash value.</li>
<li>SHA1 = 160-bit hash value.</li>
<li>SHA224 = 224-bit hash value.</li>
<li>SHA256 = 256-bit hash value.</li>
<li>SHA384 = 384-bit hash value.</li>
<li>SHA512 = 512-bit hash value.</li>
</ul>
<p><strong>Other Important Hashing Functions:</strong></p>
<blockquote><p><strong>digest() :</strong><br />
It computes a binary hash of the given data. It supports all standard algorithms like: md5, sha1, sha224, sha256, sha384 and sha512.<br />
We can use ENCODE() to convert a binary string into hexadecimal.</p><pre class="crayon-plain-tag">SELECT ENCODE(DIGEST('AnveshPassword','md5'),'hex');
SELECT ENCODE(DIGEST('AnveshPassword','sha1'),'hex');
SELECT ENCODE(DIGEST('AnveshPassword','sha224'),'hex');
SELECT ENCODE(DIGEST('AnveshPassword','sha256'),'hex');
SELECT ENCODE(DIGEST('AnveshPassword','sha384'),'hex');
SELECT ENCODE(DIGEST('AnveshPassword','sha512'),'hex');</pre><p>
</p></blockquote>
<blockquote>
<p><strong>hmac() :</strong><br />
It calculates hashed MAC for data with the key. This is similar to digest(), but more secure because it requires the key.We can use ENCODE() to convert a binary string into hexadecimal.</p><pre class="crayon-plain-tag">SELECT ENCODE(HMAC('AnveshPassword','mykey','md5'),'hex');
SELECT ENCODE(HMAC('AnveshPassword','mykey','sha1'),'hex');
SELECT ENCODE(HMAC('AnveshPassword','mykey','sha224'),'hex');
SELECT ENCODE(HMAC('AnveshPassword','mykey','sha256'),'hex');
SELECT ENCODE(HMAC('AnveshPassword','mykey','sha384'),'hex');
SELECT ENCODE(HMAC('AnveshPassword','mykey','sha512'),'hex');</pre><p>
</p></blockquote>
<blockquote>
<p><strong>crypt() and gen_salt() :</strong><br />
This is more secure than any other cryptographic functions.<br />
This is specially designed for hashing passwords.<br />
crypt() does the hashing and gen_salt() prepare algorithm parameters for it.</p>
<p>Generally, when we are using another algorithm like md5(), it generates the same string for same password text.</p>
<p><strong><code>The most important point is, it generates a random string even for same password text. </code></strong></p>
<p><strong>Supported algorightms for crypt():</strong><br />
<a href="http://www.postgresql.org/docs/9.4/static/pgcrypto.html" target="_blank">Reference taken from the PostgreSQL official document.</a></p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLGen_SaltAlgorithms.png" rel="attachment wp-att-1863"><img loading="lazy" decoding="async" class="alignnone wp-image-1863 size-full" title="PostgreSQL Gen_Salt Algorithms" src="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLGen_SaltAlgorithms.png" alt="PostgreSQL Gen_Salt Algorithms" width="660" height="128" srcset="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLGen_SaltAlgorithms.png 660w, https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLGen_SaltAlgorithms-300x58.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLGen_SaltAlgorithms-150x29.png 150w" sizes="auto, (max-width: 660px) 100vw, 660px" /></a></p>
<p><strong>Below is a small demonstration of this:<br />
</strong></p>
<p><strong>Create a sample table:</strong></p><pre class="crayon-plain-tag">CREATE TABLE tbl_TestPassword (MyPassword TEXT);</pre><p>
<p><strong>Insert a sample encrypted passwords:</strong></p><pre class="crayon-plain-tag">INSERT INTO tbl_TestPassword VALUES (CRYPT('AnveshPassword', GEN_SALT('md5')));
INSERT INTO tbl_TestPassword VALUES (CRYPT('AnveshPassword', GEN_SALT('md5')));
INSERT INTO tbl_TestPassword VALUES (CRYPT('MyNewPassword', GEN_SALT('md5')));</pre><p>
<p><strong>Check the result and identify different string for even a same password:</strong></p><pre class="crayon-plain-tag">SELECT *FROM tbl_TestPassword;</pre><p>
<a href="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLCryptoPassword.png" rel="attachment wp-att-1862"><img loading="lazy" decoding="async" class="alignnone wp-image-1862 size-full" title="PostgreSQL Crypto Password" src="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLCryptoPassword.png" alt="PostgreSQL Crypto Password" width="279" height="88" srcset="https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLCryptoPassword.png 279w, https://www.dbrnd.com/wp-content/uploads/2016/03/PostgreSQLCryptoPassword-150x47.png 150w" sizes="auto, (max-width: 279px) 100vw, 279px" /></a></p>
<p><strong>Check and authenticate given password: </strong></p><pre class="crayon-plain-tag">SELECT *FROM tbl_TestPassword WHERE MyPassword = (CRYPT('AnveshPassword', MyPassword));

-- It returns two records.

SELECT *FROM tbl_TestPassword WHERE MyPassword = (CRYPT('MyNewPassword', MyPassword));

-- It returns one record.</pre><p>
</p></blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/03/postgresql-best-way-for-password-encryption-using-pgcryptos-cryptographic-functions/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
	</channel>
</rss>
