<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pieter Linde on Medium]]></title>
        <description><![CDATA[Stories by Pieter Linde on Medium]]></description>
        <link>https://medium.com/@pieterdlinde?source=rss-ae9815fbd575------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YMxUM9r76jsN_eVY</url>
            <title>Stories by Pieter Linde on Medium</title>
            <link>https://medium.com/@pieterdlinde?source=rss-ae9815fbd575------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 01:51:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pieterdlinde/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular RSA + AES Encryption - .NetCore Decryption]]></title>
            <link>https://pieterdlinde.medium.com/angular-rsa-aes-encryption-netcore-decryption-1008902286b9?source=rss-ae9815fbd575------2</link>
            <guid isPermaLink="false">https://medium.com/p/1008902286b9</guid>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[rsa]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[webapi]]></category>
            <dc:creator><![CDATA[Pieter Linde]]></dc:creator>
            <pubDate>Sun, 07 Feb 2021 10:27:43 GMT</pubDate>
            <atom:updated>2021-02-07T10:38:08.806Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular RSA + AES Encryption - .NetCore WebApi Decryption (Public/Private Key +<strong>Advanced Encryption Standard</strong> Cryptography)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-W4Agbde33A5wtHhu3SyQ.png" /><figcaption>Angular RSA + AES Encryption — .NetCore WebApi Decryption (Public/Private Key +Advanced Encryption Standard Cryptography)</figcaption></figure><h3>Before we begin -&gt;</h3><p>This is a follow up on the post I wrote about <strong>Angular RSA Encryption - .NetCore WebApi Decryption (Public/Private Key Cryptography)</strong></p><p>Give this a read before you scroll down too far.</p><p><a href="https://pieterdlinde.medium.com/angular-rsa-encryption-netcore-decryption-public-private-key-78f2770f955f">Angular RSA Encryption — .NetCore WebApi Decryption (Public/Private Key Cryptography)</a></p><p><strong>Recap on RSA</strong></p><p>Private, public keys? Let’s think about a door in a house. The door is the color red, that way we are all on the same page with the door color 😁. A door with a weird lock 🔐. A door that can only be locked with one key and can only be unlocked by a different key. Dumb down a lot- That is the same rules/principles that is being used with RSA encryption. Please read the post above for a more information or the wiki page below</p><blockquote><a href="https://simple.wikipedia.org/wiki/RSA_algorithm#:~:text=RSA%20%28Rivest%E2%80%93Shamir%E2%80%93Adleman,can%20be%20given%20to%20anyone">https://simple.wikipedia.org/wiki/RSA_algorithm#:~:text=RSA%20%28Rivest%E2%80%93Shamir%E2%80%93Adleman,can%20be%20given%20to%20anyone</a>.</blockquote><h3>AES encryption?!</h3><p>This is a bit more difficult to dumb down 😁, so I am not going to try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/0*E3hT2JIFeJbHWWsi.jpg" /></figure><p>Wiki Page</p><p><a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard">Advanced Encryption Standard - Wikipedia</a></p><h3><strong>The Goal</strong></h3><p>Going from this-&gt;</p><blockquote><em>{userName: “Pieter@email.com”, password: “ThisIsAPassword”}</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x4No7R16FLJFUmsh.png" /></figure><p>To this -&gt;</p><blockquote>{“data”:”AWL1DESM6YWwFnZJ+1MrADU96AEESw7S39Tqkt2oOEDn3otGKACIWzpgOCKPwpmWWOI41qF6hlLV3LN4nky8sHlobQT/G0AcYgLcujAJQrY=”,”aesKey”:”VMTesoorpwfL/CeqO0pJVZbtVY7Yv3ESng5BOKfKqJ265/K1IlYacYepM0L17JOUzPt15ih80+0RWPTZG99/uYvzEwjKeZYNq25N9wxJcrV1gaaiefhF8y7ehtF7Q8teeefIhzasOD4Z0HKPLe3qv/RTqT6XwW59QYDGa3SqSbk=”}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F5ylA_-LF6Zg3aL4DLhlrg.png" /></figure><h3><strong>Angular RSA Recap</strong></h3><p><strong>(Full medium post referenced at the top of the page)</strong></p><h3>Create a Public and Private Key’s</h3><p>The first thing we need to do is create a public and private key.</p><p>For this example, I am just going to create a plain and simple key using this awesome online tool</p><p><a href="https://travistidwell.com/jsencrypt/demo/">Online RSA Key Generator</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3oxK_Te3dacHEDMQ.png" /></figure><p>Remember to save the two key’s on a secure place</p><p><strong>Angular RSA Helper</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e82b8af7f369e9ad0d109a402f467fb7/href">https://medium.com/media/e82b8af7f369e9ad0d109a402f467fb7/href</a></iframe><h3>AES Angular Setup</h3><p>If you are reading this, you already have or know how to setup a angular project 😁 (Or please find the source code link at the bottom of the page)</p><p><strong>NPM Packages you need for AES</strong></p><pre>npm install crypto-js</pre><pre>npm install @types/crypto-js</pre><p><strong>AES Helper</strong></p><p>CipherMode (Specifies the block cipher mode to use for encryption.). Make sure the mode that you select on the Angular project matched the mode in the .NetCore WebApi project</p><p>CipherModes -CBC,CTS,ECB</p><p>PaddingMode (Specifies the type of padding to apply when the message data block is shorter than the full number of bytes needed for a cryptographic operation.). Make sure the mode that you select on the Angular project matched the mode in the .NetCore WebApi project</p><p>PaddingModes -ANSIX923, ISO10126,None,PKCS7,Zeros</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d9c46683977e0f868541aed5da7051d/href">https://medium.com/media/6d9c46683977e0f868541aed5da7051d/href</a></iframe><h3>HTTP Request</h3><p><strong>Basic Login</strong></p><p>This does no encryption</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/412fd4901b1ac45646ae7d67a2fe8e08/href">https://medium.com/media/412fd4901b1ac45646ae7d67a2fe8e08/href</a></iframe><p><strong>AES + RSA Encrypted Login</strong></p><p>This encrypts the username and the password</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6120791347242f7998ccdedc1c6eb538/href">https://medium.com/media/6120791347242f7998ccdedc1c6eb538/href</a></iframe><p><strong>AES + RSA Encrypted Login (A bit more secure)</strong></p><p>Converts the user object to json and then encrypts the json</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8022ba4256d9a49936cc97da0f9520e2/href">https://medium.com/media/8022ba4256d9a49936cc97da0f9520e2/href</a></iframe><h3>.NetCore RSA Recap</h3><p><strong>(Full medium post referenced at the top of the page)</strong></p><p>If you are reading this, you already have or know how to setup a WebApi project 😁 (Or please find the source code link at the bottom of the page)</p><p><strong>RSA Helper</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a79e521665f1ebf17d5537a399edb25/href">https://medium.com/media/4a79e521665f1ebf17d5537a399edb25/href</a></iframe><p><strong>Create a AES Helper Interface</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/108f0d9f51b3634eee615f2535fc5d7f/href">https://medium.com/media/108f0d9f51b3634eee615f2535fc5d7f/href</a></iframe><p><strong>Create the AES Helper</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64731d6d9ce8e7414d01d1223659e46d/href">https://medium.com/media/64731d6d9ce8e7414d01d1223659e46d/href</a></iframe><p>*Remember to inject your helper class</p><h3>HTTP Request</h3><p>Create a UserController and inject the RSA and AES Helpers</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed6c2724a97e597cc5de3b00e209ab79/href">https://medium.com/media/ed6c2724a97e597cc5de3b00e209ab79/href</a></iframe><p><strong>Basic Login</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/227f24161a14bdd1788ac5552ee3ee60/href">https://medium.com/media/227f24161a14bdd1788ac5552ee3ee60/href</a></iframe><p><strong>Encrypted Login</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d2f1d0702a7dc0ba54a3e159e78a95e/href">https://medium.com/media/6d2f1d0702a7dc0ba54a3e159e78a95e/href</a></iframe><p><strong>Encrypted Login (A bit more secure)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dfaeaa2fa39ab47104ec67d71925295/href">https://medium.com/media/7dfaeaa2fa39ab47104ec67d71925295/href</a></iframe><h3>Summary</h3><p>If this helped you in any way or you just think this is cool, give it a 👍!</p><p><a href="https://www.linkedin.com/in/pieter-linde-518b08119/">Pieter Linde - Software Architect - iOCO | LinkedIn</a></p><h3>Git Repo</h3><p>Angular Git Repo -&gt;</p><p><a href="https://github.com/pieterdlinde/Angular-AES-RSA">https://github.com/pieterdlinde/Angular-AES-RSA</a></p><p>NetCore Web Api Git Repo -&gt;</p><p><a href="https://github.com/pieterdlinde/DotNet-AES-RSA">https://github.com/pieterdlinde/DotNet-AES-RSA</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1008902286b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular RSA Encryption — .NetCore WebApi Decryption (Public/Private Key Cryptography)]]></title>
            <link>https://pieterdlinde.medium.com/angular-rsa-encryption-netcore-decryption-public-private-key-78f2770f955f?source=rss-ae9815fbd575------2</link>
            <guid isPermaLink="false">https://medium.com/p/78f2770f955f</guid>
            <category><![CDATA[webapi]]></category>
            <category><![CDATA[rsa]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Pieter Linde]]></dc:creator>
            <pubDate>Sat, 06 Feb 2021 21:27:36 GMT</pubDate>
            <atom:updated>2021-02-07T10:25:29.233Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular RSA Encryption - .NetCore WebApi Decryption (Public/Private Key C<strong>ryptography</strong>)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r3XGVEH6t8uJphuYhGjFDg.png" /><figcaption>Angular RSA Encryption .NetCore Decryption</figcaption></figure><h3>RSA encryption?!</h3><p>Private, public keys? Let’s think about a door in a house. The door is the color red, that way we are all on the same page with the door color 😁. A door with a weird lock 🔐. A door that can only be locked with one key and can only be unlocked by a different key. Dumb down a lot- That is the same rules/principles that is being used with RSA encryption. Please read the wiki page for a full explanation</p><p><a href="https://simple.wikipedia.org/wiki/RSA_algorithm#:~:text=RSA%20(Rivest%E2%80%93Shamir%E2%80%93Adleman,can%20be%20given%20to%20anyone.">RSA algorithm</a></p><p>In this post we are going to use this encryption type (RSA) to encrypt data to look like this-&gt;</p><blockquote>{userName: “Pieter@email.com”, password: “ThisIsAPassword”}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9G_Vd5IpnGH3AVs_EY4wgA.png" /></figure><blockquote>{“userName”:”JPvuJybOyhkYGZWikp9VVjjBXYOhyutPK3/UAKJI6h89mAxtf2DdBwSUlLyJerPi/iAs7eE8TdHXCVu0P0qIly5L+GwsDo4zIfceV4cM1Zvf8LE+eUqur0/pLvWDTorVapy6afTqq0bHDHPcwrMn+JO9G5Gn4HPdnEG3Ctcg9g0=”,”password”:”ScJYknMSSrog/qZVrkL3AHaYLLK03BfhF26ookZFFHxNTDfNKk2bSLy5fnhsjmIJ2fMuZ0ACDl/B6uxC3uQcXvWwB8w7bxDdFctIfNvkhVvImjyiKBnJSNe2+Fy6mrP43d39o17hxN14XUE5CRbOoI1fnzdypp0FTTDH1iNbGx8=”}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5QsO3KmQrQ9daVQki1yPQ.png" /></figure><blockquote>{“data”:”PyUD0znSNZ+hT2CmT+YDiyDF8N7qG/AHn9XlkGnBA+QkcKpXRk5WagMNSFigFxxgvVb5ZJJQ/j1PtFicwtBDb+/eIsUNV815zBV2tQkO8l6mC2wrBUt5UsX0br0RAl+39cuJSnzFz1qhaqw7xWlDhuldBD4tW4MdEXtU2yQa5qM=”}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sSqeCDEQidDdVPMidmEgAQ.png" /></figure><h3><strong>Public and Private Key’s</strong></h3><p>The first thing we need to do is create a public and private key.</p><p>For this example, I am just going to create a plain and simple key using this awesome online tool:</p><p><a href="https://travistidwell.com/jsencrypt/demo/">Online RSA Key Generator</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R72S-DjTqR8rrNYRnTd_6A.png" /></figure><p>Once you made a copy of the two key’s and saved it somewhere securely, we can now start and do some coding.</p><h3><strong>Angular Setup</strong></h3><p>If you are reading this, you already have or know how to setup a angular project 😁 (Or please find the source code link at the bottom of the page)</p><p><strong>NPM Packages you need</strong></p><pre>npm install node-forge</pre><pre>npm install @types/node-forge</pre><p><strong>RSA Helper</strong></p><p><strong>ONLY</strong> the public key should be in the source code of the angular application. If both private and public keys are on the same code/application you have missed the mark.</p><p>For this example I am just going to add the public key as a string in my service (On the dotnet part, I will create a .pem file):</p><pre>publicKey: string = `-----BEGIN PUBLIC KEY-----</pre><pre>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCEKfugJmnCR4hvQdF59dOUKyW/</pre><pre>5TpNcN1p2dNqtDbEYM9od3/K0MmnN4wk5IGnkaejT1BISRjAIQ7LVUorr/c0UoPQ</pre><pre>AWdAXsX12DYxZIpaAQ/J+GMOHXNTcT3bWmZuZXUoR+usP1rlwYwlsimuPmdCXpNn</pre><pre>IZGLTEVLs5rFeafNbQIDAQAB</pre><pre>-----END PUBLIC KEY-----`;</pre><p>Next we are going to use the Forge Package and the public key to encrypt our string value:</p><pre>const rsa = Forge.pki.publicKeyFromPem(this.publicKey);</pre><pre>return btoa(rsa.encrypt(valueToEncrypt.toString()));</pre><p><strong>Full RSA Helper</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3be86cd322781c8e3beb8dbc1fa507d/href">https://medium.com/media/d3be86cd322781c8e3beb8dbc1fa507d/href</a></iframe><h3><strong>HTTP Request</strong></h3><p><strong>Basic Login</strong></p><p>This does no encryption</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d2c33e8c9fce248b55b2e1326760483/href">https://medium.com/media/4d2c33e8c9fce248b55b2e1326760483/href</a></iframe><p><strong>Encrypted Login</strong></p><p>This encrypts the username and the password</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aec46be3878a2d124563a41909233ed6/href">https://medium.com/media/aec46be3878a2d124563a41909233ed6/href</a></iframe><p><strong>Encrypted Login (A bit more secure)</strong></p><p>Converts the user object to json and then encrypts the json</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/969744367a9aa45fc147c04742670508/href">https://medium.com/media/969744367a9aa45fc147c04742670508/href</a></iframe><h3>.NetCore Setup (WebApi)</h3><p>If you are reading this, you already have or know how to setup a WebApi project 😁 (Or please find the source code link at the bottom of the page)</p><p><strong>NuGet Packages you need</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*Nv3nTd3G52R8bzjIEfG-Cw.png" /></figure><p><strong>RSA Helper</strong></p><p><strong>ONLY</strong> the private key should be in the source code of the WebApi application. If both private and public keys are on the same code/application you have missed the mark.</p><p>Save your Private key into a .pem file -&gt; past the private key into the .pem file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*JoiBIh7lH6UstkiYXTeFMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tiQriLAN6XKSF_8D35NRw.png" /></figure><p>Create a IRSAHelper Interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4edef68343d10291eb390a85cfd6bdb0/href">https://medium.com/media/4edef68343d10291eb390a85cfd6bdb0/href</a></iframe><p>Create the RSAHelper:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26064320883f37b18f4f82574b4cb102/href">https://medium.com/media/26064320883f37b18f4f82574b4cb102/href</a></iframe><p>*Remember to inject your helper class</p><h3>HTTP Request</h3><p>Create a UserController and inject the RSA Helper</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6113b75322633bd8ce119d44054db696/href">https://medium.com/media/6113b75322633bd8ce119d44054db696/href</a></iframe><p><strong>Basic Login</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0731d367c1b5bf1d77d40be49043c9c/href">https://medium.com/media/d0731d367c1b5bf1d77d40be49043c9c/href</a></iframe><p><strong>Encrypted Login</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e18b7591e87b95240745f5e16ba6dcf0/href">https://medium.com/media/e18b7591e87b95240745f5e16ba6dcf0/href</a></iframe><p><strong>Encrypted Login (A bit more secure)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bad8e0cff506894fcd50c30c70905270/href">https://medium.com/media/bad8e0cff506894fcd50c30c70905270/href</a></iframe><h3><strong>Summary</strong></h3><p>If this helped you in any way or you just think this is cool, give it a 👍!</p><p><a href="https://www.linkedin.com/in/pieter-linde-518b08119/">Pieter Linde - Software Architect - iOCO | LinkedIn</a></p><h3><strong>Git Repo</strong></h3><p>Angular Git Repo -&gt;</p><p><a href="https://github.com/pieterdlinde/Angular-RSA">https://github.com/pieterdlinde/Angular-RSA</a></p><p>.NetCore Web Api Git Repo -&gt;</p><p><a href="https://github.com/pieterdlinde/DotNet-AES-RSA">https://github.com/pieterdlinde/DotNet-AES-RSA</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78f2770f955f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[.NetCore and Cloud Firestore]]></title>
            <link>https://pieterdlinde.medium.com/netcore-and-cloud-firestore-94628943eb3c?source=rss-ae9815fbd575------2</link>
            <guid isPermaLink="false">https://medium.com/p/94628943eb3c</guid>
            <category><![CDATA[firestore]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[cloud-firestore]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Pieter Linde]]></dc:creator>
            <pubDate>Fri, 20 Nov 2020 22:06:38 GMT</pubDate>
            <atom:updated>2022-08-02T18:39:39.961Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTyhu1csyxHeprGkl_RlbQ.png" /><figcaption>.NetCore Firestore WebApi</figcaption></figure><p>Cloud Firestore is a great way to store your data in a new and easy way. Firestore is a NoSQL database that is flexible, scalable and that can be used for web, mobile and other types of implementation. This tutorial will show you how to connect your C# project to a Firestore database.</p><h3>Firebase Setup</h3><p>Before we get started, the first thing we need to do is set up our Firebase environment. (<a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a>)</p><p>If you don’t have a firebase project created already, you will have to create a new project. It is as easy as clicking “A<em>dd project”.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4hpitL_E9wDXw8Sojv57w.png" /></figure><p>After you followed the initial setup steps and your new firebase project has been successfully created, we need to make sure your Cloud Firestore is up and running. Find the menu items called <em>Cloud Firestore</em> on the left side of your window, click on the button <em>Create database</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERHZcykVVFO2fTK2v0LMFQ.png" /></figure><p>For this tutorial the rule set, we are using - <strong>Test Mode.</strong></p><p>And that&#39;s it! Your firestore is ready for your data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPtE7_6p8CZchZK6cGXRnQ.png" /></figure><p>Create a new private key, this key will be used to connect your API project to the Firestore. (Take note of where this file is saved)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mOvRwk7LJk6KrohpNvBfw.png" /></figure><h3>.Net Core API Setup</h3><p>For this tutorial we are going to use ASP.NET Core (Web Api) to implement a simple way to communicate with a Firestore database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9PqXRQriLP6sSILa4RgkMw.png" /></figure><p>Install the Nuget Package — google.cloud.firestore (<a href="https://github.com/googleapis/google-cloud-dotnet">https://github.com/googleapis/google-cloud-dotnet</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXUWN1tXZtA0JhqxzyNXjw.png" /></figure><p><strong>Model Setup</strong></p><p>We will save <em>Users</em> to a Firestore table. The <em>Base</em> class will be the properties shared by all the models that you save inside your database. In the example we will only have one shared property - Id. Both your <em>User Class </em>and <em>City Class </em>must inherit from the Base class.</p><p>Also, don’t forget to add the [FirestoreData] above your models -&gt; This indicates that the model can be saved in the database.</p><p>The [FirestoreProperty] is also important, only properties with this value assigned will be saved into the database. The property <em>NotBeingSaved </em>will not be saved in the database</p><p>(Github Code: <a href="https://github.com/pieterdlinde/firestore-test-application">https://github.com/pieterdlinde/firestore-test-application</a>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c1bd9f823a3754b229c0c4943f05782/href">https://medium.com/media/9c1bd9f823a3754b229c0c4943f05782/href</a></iframe><p><strong>Interface Setup</strong></p><p>The Firestore interface will give you a generic way to call your get’s, add’s and delete in a simple way. (Just wait, you will see)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43952aae38524f9432eef68e395a4e74/href">https://medium.com/media/43952aae38524f9432eef68e395a4e74/href</a></iframe><p><strong>Base Repository Setup</strong></p><p>We will be able to use this generic class to access the Firestore environment.</p><p>In the section file path<em> </em>- You will need to reference the private key you downloaded from the Firebase website.</p><p>For this example, we are just hardcoding the path to the credentials JSON file, but you can also use the DbBuilder.</p><pre><em>FirestoreDb firestormDb = new FirestoreDbBuilder{</em></pre><pre><em>ProjectId = &quot;projectName&quot;,</em></pre><pre><em>JsonCredentials = &quot;jsonCredentialsString&quot;</em></pre><pre><em>}.Build();</em></pre><blockquote>string filepath = &quot;/Users/MyPCUser/Downloads/-firebase-adminsdk-ivk8q-d072fdf334.json&quot;;</blockquote><p><a href="https://gist.github.com/pieterdlinde/7facb9562df440d757cc2e58aa5ad80b">https://gist.github.com/pieterdlinde/7facb9562df440d757cc2e58aa5ad80</a>b</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VdAMEViiy2oeDD7_cLjTcw.png" /></figure><p><strong>User Repository Setup</strong></p><p>Remember to implement the FirestoreInterface and pass in the class <em>User.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a7ce04254cabad6697e2009d312bdcc/href">https://medium.com/media/2a7ce04254cabad6697e2009d312bdcc/href</a></iframe><p>Now all you need to do is set up your controller and point it to the correct repository. I do recommend not calling your repositories directly from the controller, but rather using a <em>Workflow</em> and a <em>Service</em> Layer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05d07a6ea96c31e314dfee922907a0c8/href">https://medium.com/media/05d07a6ea96c31e314dfee922907a0c8/href</a></iframe><p>One tool that I recommend is - FluentValidation. <a href="https://fluentvalidation.net/">https://fluentvalidation.net/</a></p><p>This will ensure that the data going into your database is valid and correct.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QvxnuVQ9wb9k_zxDKuw50Q.png" /></figure><p>Github Code:</p><p><a href="https://github.com/pieterdlinde/firestore-test-application">GitHub - pieterdlinde/firestore-test-application</a></p><p>References: <a href="https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Firestore/">https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Firestore/</a></p><p><a href="https://developers.google.com/api-client-library/dotnet/apis/firestore/v1">https://developers.google.com/api-client-library/dotnet/apis/firestore/v1</a></p><p>Thank you for reading my first Medium post :)</p><h3>Summary</h3><p>If this helped you in any way or you just think this is cool, give it a 👍!</p><p><a href="https://www.linkedin.com/in/pieter-linde-518b08119/">Pieter Linde - Software Architect - iOCO | LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94628943eb3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>