<?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>extension &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/extension/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>Wed, 22 Nov 2017 11:39:26 +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>PostgreSQL: Best Practice &#8211; Create Extension in Schema</title>
		<link>https://www.dbrnd.com/2017/12/postgresql-best-practice-create-extension-in-schema/</link>
					<comments>https://www.dbrnd.com/2017/12/postgresql-best-practice-create-extension-in-schema/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 14 Dec 2017 16:16:55 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dblink]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[extension]]></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 Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[search_path]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6810</guid>

					<description><![CDATA[In this post, I am sharing a best practice of creating any extension in Schema of PostgreSQL. Using Extension, we can add additional functionality in PostgreSQL. If we do not provide any schema specification, it will create under search_path schema which PUBLIC most of the time. PostgreSQL: The Schema Search Path and change the default [&#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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&amp;linkname=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" 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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&amp;linkname=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" 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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&amp;linkname=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" 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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&amp;linkname=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" 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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&amp;linkname=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" 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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&amp;linkname=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" 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%2F12%2Fpostgresql-best-practice-create-extension-in-schema%2F&#038;title=PostgreSQL%3A%20Best%20Practice%20%E2%80%93%20Create%20Extension%20in%20Schema" data-a2a-url="https://www.dbrnd.com/2017/12/postgresql-best-practice-create-extension-in-schema/" data-a2a-title="PostgreSQL: Best Practice – Create Extension in Schema"></a></p><p>In this post, I am sharing a best practice of creating any extension in Schema of PostgreSQL.</p>
<p>Using Extension, we can add additional functionality in PostgreSQL.<br />
If we do not provide any schema specification, it will create under search_path schema which PUBLIC most of the time.</p>
<blockquote class="wp-embedded-content" data-secret="l320OB7rS6"><p><a href="https://www.dbrnd.com/2016/08/postgresql-the-schema-search-path-and-change-the-default-public-schema/">PostgreSQL: The Schema Search Path and change the default PUBLIC Schema</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-the-schema-search-path-and-change-the-default-public-schema/embed/#?secret=l320OB7rS6" data-secret="l320OB7rS6" width="600" height="338" title="&#8220;PostgreSQL: The Schema Search Path and change the default PUBLIC Schema&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Now, why we should create an extension in schema?</strong></p>
<blockquote><p>For example, I created a &#8216;dblink&#8217; extension without schema specification and I am using dblink functions without giving any schema name because it formed in search_path schema. </p>
<p>But, If I create a &#8216;dblink&#8217; extension in dblink schema, we have to access dblink features by specifying the schema name of that extension. This is also good for code and other management as a backup of the schema.</p></blockquote>
<p><strong>Check the below example:</strong></p>
<p><strong>Create a user-defined schema:</strong></p>
<pre class="crayon-plain-tag">CREATE SCHEMA dblink;</pre> </p>
<p><strong>Create a dblink extension, under dblink schema:</strong></p>
<pre class="crayon-plain-tag">CREATE EXTENSION dblink WITH SCHEMA dblink;</pre> </p>
<blockquote class="wp-embedded-content" data-secret="yQ4Cqs0mbq"><p><a href="https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/">PostgreSQL [Video]: Cross Database Queries using DbLink Extension</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/05/postgresql-cross-database-queries-using/embed/#?secret=yQ4Cqs0mbq" data-secret="yQ4Cqs0mbq" width="600" height="338" title="&#8220;PostgreSQL [Video]: Cross Database Queries using DbLink Extension&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/12/postgresql-best-practice-create-extension-in-schema/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>PostgreSQL 9.6: Introduced pg_visibility module to examine visibility map</title>
		<link>https://www.dbrnd.com/2017/04/postgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 11 Apr 2017 16:16:34 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[Free Space Map]]></category>
		<category><![CDATA[generate_series]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[pg_visibility]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL 9.6]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[visibility map]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5016</guid>

					<description><![CDATA[If you don&#8217;t know what VM and FSM is, I would suggest to read below articles: PostgreSQL: What is Visibility Map (VM)? PostgreSQL: What is a Free Space Map (FSM)? PostgreSQL 9.6 introduced a pg_visibility module to get the visibility map information of your table, and it is also giving page level information. For removing [&#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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" 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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" 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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" 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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" 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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" 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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" 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%2Fpostgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map%2F&#038;title=PostgreSQL%209.6%3A%20Introduced%20pg_visibility%20module%20to%20examine%20visibility%20map" data-a2a-url="https://www.dbrnd.com/2017/04/postgresql-9-6-introduced-pg_visibility-module-to-examine-visibility-map/" data-a2a-title="PostgreSQL 9.6: Introduced pg_visibility module to examine visibility map"></a></p><p>If you don&#8217;t know what VM and FSM is, I would suggest to read below articles:</p>
<blockquote data-secret="pTZNKHe5td" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/10/postgresql-what-is-visibility-map-vm-table-mvcc-architecture/">PostgreSQL: What is Visibility Map (VM)?</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/10/postgresql-what-is-visibility-map-vm-table-mvcc-architecture/embed/#?secret=pTZNKHe5td" data-secret="pTZNKHe5td" width="600" height="338" title="&#8220;PostgreSQL: What is Visibility Map (VM)?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote data-secret="uPHRViR537" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/10/postgresql-what-is-a-free-space-map-fsm-table-mvcc-architecture/">PostgreSQL: What is a Free Space Map (FSM)?</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/10/postgresql-what-is-a-free-space-map-fsm-table-mvcc-architecture/embed/#?secret=uPHRViR537" data-secret="uPHRViR537" width="600" height="338" title="&#8220;PostgreSQL: What is a Free Space Map (FSM)?&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote><p>PostgreSQL 9.6 introduced a pg_visibility module to get the visibility map information of your table, and it is also giving page level information.<br />
For removing fragmentation, and improve the query performance we should check the visibility map of our table. </p></blockquote>
<p>For that, you need to create a pg_visibility module in PostgreSQL 9.6 and use it.<br />
Previously, people are checking the suffix _vm files which associate with your relation. </p>
<p><strong>Check the below demonstration on how to use pg_visibility:</strong></p>
<p><strong>Create a pg_visibility extension:</strong></p>
<pre class="crayon-plain-tag">CREATE EXTENSION pg_visibility;</pre> </p>
<p><strong>Create a sample table with 10000 dummy records:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_checkvmap AS SELECT generate_series(1,10000) AS id;</pre> </p>
<p><strong>Check the visibility map:</strong></p>
<pre class="crayon-plain-tag">SELECT * FROM pg_visibility('tbl_checkvmap'::regclass);</pre> </p>
]]></content:encoded>
					
		
		
			</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>
