<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gál Péter</title>
    <description>The latest articles on DEV Community by Gál Péter (@pepyta).</description>
    <link>https://dev.to/pepyta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F358862%2Fa9ce3512-2383-4113-880a-9b4e04cb2fb9.png</url>
      <title>DEV Community: Gál Péter</title>
      <link>https://dev.to/pepyta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pepyta"/>
    <language>en</language>
    <item>
      <title>Encryption without passwords</title>
      <dc:creator>Gál Péter</dc:creator>
      <pubDate>Sun, 11 Jul 2021 14:16:30 +0000</pubDate>
      <link>https://dev.to/wault/encryption-without-passwords-57bj</link>
      <guid>https://dev.to/wault/encryption-without-passwords-57bj</guid>
      <description>&lt;p&gt;In modern encryption, you need a key/password/secret to be able to securely encrypt/decrypt data. This is the idea behind symmetric encryption. In this article, I'm going to drive you through how is the security provided without ever needing to remember a password.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can we encrypt something in the first place?
&lt;/h3&gt;

&lt;p&gt;There are lots of ways to encrypt something. When it comes to storing your information on a Safe, we are using an asymmetric encryption method, called AES-256 (Advanced Encryption Standard).&lt;/p&gt;

&lt;p&gt;When we create a new safe, we generate a new secret key with them. This will be then used to encrypt all of our data in that particular safe. We are using a 128-character long hex string as our secret (512 bits), which is much more secure, than any password that we could remember.&lt;/p&gt;

&lt;p&gt;Then this encryption key is stored in the device's secure storage.&lt;/p&gt;

&lt;p&gt;Here is how this works out in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Generating a new secret&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;secret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;generateSecret&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Storing it in the device's secure storage&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;SecureStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// This is the data, that we want to store&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dev.to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john@doe.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret123&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Then we encrypt the data&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;AES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Sending the user to the database&lt;/span&gt;
&lt;span class="c1"&gt;// The safe is an object, where we want to store the item inside&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;safe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// And finally, on a remote device, when we want to access the data, we use the secret to decrypt&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;decrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;AES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// It would print the original user object ({ platform: "dev.to", username.... })&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decrypted&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: this is just a presentation of how things work... you should just consider it as a pseudo-code, instead of an actual working example&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  How can we transfer this key from one device to another safely?
&lt;/h3&gt;

&lt;p&gt;This is a tricky one. If we would just send the encryption key through our database unencrypted, it would mean that there is no point of encryption as we would store the secret key next to the encrypted data. It would mean that you can just use that key to decrypt the data that is stored in the database.&lt;/p&gt;

&lt;p&gt;Instead, we use an asymmetric encryption method, called RSA-2048. When you generate a new RSA key, then it is generating a keypair. A public one and a private one.&lt;/p&gt;

&lt;p&gt;The public one can be only used to encrypt data. It can be safely shared on the network, as it provides no way for a potential attacker to retrieve data from the hash, as it is not eligible for that.&lt;/p&gt;

&lt;p&gt;The private one will stay on the original device without ever sharing it with another device. Then when we get data from the server, we can use this key to decrypt the hash, that we received.&lt;/p&gt;

&lt;p&gt;Let's see, how does it work out in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When a device is added to the network, we generate this key pair and send the public key to the database. It will be stored in the future.&lt;/li&gt;
&lt;li&gt;We create a new safe on one of our devices and generate a secret, that is stored locally.&lt;/li&gt;
&lt;li&gt;We query all of our devices from the database with their RSA public keys.&lt;/li&gt;
&lt;li&gt;Then we encrypt the secret, that we generated at the #2 step with this key.&lt;/li&gt;
&lt;li&gt;Then we add an entry called KeyExchange, which contains information about which device and safe is the key meant for and the &lt;em&gt;encrypted&lt;/em&gt; secret.&lt;/li&gt;
&lt;li&gt;Finally when we refresh our data on another device, we query all of our key exchanges and decrypt them with our private RSA key.&lt;/li&gt;
&lt;li&gt;After the device received the encryption key, we can safely delete the key from our database as it will be no longer needed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How can I log in from another device?
&lt;/h3&gt;

&lt;p&gt;Compared to ordinary systems, when we log in, we also exchange a lot of data between the &lt;code&gt;Authenticator&lt;/code&gt; and the &lt;code&gt;Authenticated&lt;/code&gt; device.&lt;/p&gt;

&lt;p&gt;Authenticator: The device, that is already logged in.&lt;br&gt;
Authenticated: The device, that we want to log in, but is not yet authenticated.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;Authenticated&lt;/code&gt; device generates an RSA key pair and sends a signal to the remote server to start the authentication process with the public key.&lt;/li&gt;
&lt;li&gt;The remote server then generate an authentication id (e.g.: &lt;code&gt;ckqz9n52r000001la810jfjee&lt;/code&gt;) and a secret (e.g.: &lt;code&gt;11879182178653d376fc6b129d1d315b&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Then the server stores the id with the &lt;code&gt;bcrypt&lt;/code&gt; hashed version of the secret in the database and sends back the secret and the id to the &lt;code&gt;Authenticated&lt;/code&gt; device.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Authenticated&lt;/code&gt; device, then generates a QR code, that stores only the ID, that it got from the server.&lt;/li&gt;
&lt;li&gt;Now on the &lt;code&gt;Authenticator&lt;/code&gt; device, we scan this QR code. This will send a signal to the remote server about who scanned the QR code (first).&lt;/li&gt;
&lt;li&gt;On the &lt;code&gt;Authenticated&lt;/code&gt; device, we will see the username of the user, who scanned this QR code.&lt;/li&gt;
&lt;li&gt;On the &lt;code&gt;Authenticator&lt;/code&gt; device, the user presses a Verify button. This will send the encryption keys from that device to the &lt;code&gt;Authenticated&lt;/code&gt; one (as described above) and this will also send a signal, to allow the remote server, to generate an access token and a refresh token for the user.&lt;/li&gt;
&lt;li&gt;While these things happen, the &lt;code&gt;Authenticated&lt;/code&gt; device pings the server, if the state has changed. If the auth process went through successfully, then it will just download all data, that has been sent to this device.&lt;/li&gt;
&lt;li&gt;On the &lt;code&gt;Authenticated&lt;/code&gt; device, we use the private RSA key, to decrypt the keys.&lt;/li&gt;
&lt;li&gt;Profit! We have successfully gained an access_token, a refresh_token, generated and exchanged the RSA keys, and also received all of the keys necessary, to decrypt the safes associated with this device. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On the &lt;code&gt;Authenticated&lt;/code&gt; device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Generate a public and a private RSA key&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;privateKey&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;RSA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2048&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Send this publicKey to the server and receive the id and the secret&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secret&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authentication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Store the private RSA key for future use&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;SecureStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rsa_private_key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;privateKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Check the server periodically for response&lt;/span&gt;
&lt;span class="nx"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authentication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;check&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;not_yet_scanned&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// If noone scanned the code yet do nothing&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scanned_but_not_verified&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// If the code has been scanned, but the code has not been verified just show the username for the user, to be able to verify, that they are allowing the right device in&lt;/span&gt;
        &lt;span class="nx"&gt;displayUsername&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Finally, if everything has been sent and verified, we can do the real job&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;exchange&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keyExchanges&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;EncryptionKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;safeid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RSA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nx"&gt;AccessToken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;access_token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;RefreshToken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;refresh_token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the &lt;code&gt;Authenticator&lt;/code&gt; device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Initialize a new QR code scanner instance&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scanner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;QRCodeScanner&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Add an event listener for scan&lt;/span&gt;
&lt;span class="nx"&gt;scanner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scan&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Tell the remote server, that the QR code has been scanned on this device&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;rsaPublicKey&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authentication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onScan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Show the username for the user&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;waitForVerification&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Get all the encryption keys&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;EncryptionKeys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getAll&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Iterate over all keys and encrypt them with the RSA key&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;enrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;safeid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;safeid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RSA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Send the keys to the device&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authentication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="c1"&gt;// The ID, that we scanned with the QR code&lt;/span&gt;
        &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;encryptedKeys&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Show success screen!&lt;/span&gt;
    &lt;span class="nx"&gt;showSuccessScreen&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Show the QRCode scanner for the user&lt;/span&gt;
&lt;span class="nx"&gt;scanner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: This code is also just serves the purpose of demonstration, implementation may vary from platform to platform&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What if I lose my device? Will I lose access to my data?
&lt;/h3&gt;

&lt;p&gt;By design, that would be the case. But we can create a backup key, that can be used in the future, to regain access to our data after we lost our phones.&lt;/p&gt;

&lt;p&gt;This backup works just like an ordinary device because it is technically a device. It will have a refresh token, to gain access to our vault and it will have an RSA private key, to decrypt the key exchanges sent to it. Ohh... and also, when we create a new vault, we will send a key exchange to this backup key.&lt;/p&gt;

&lt;p&gt;With this backup, we can provide the ability, to gain access after you lost your phone.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;br&gt;
If you have any questions, feel free to ask them below.&lt;/p&gt;

&lt;p&gt;Github organization: &lt;a href="https://github.com/wault-app"&gt;github.com/wault-app&lt;/a&gt;&lt;br&gt;
Discord: &lt;a href="https://discord.gg/NxhdAf4azz"&gt;discord.gg/NxhdAf4azz&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>crypto</category>
      <category>encryption</category>
    </item>
    <item>
      <title>Wault: The future of password managers</title>
      <dc:creator>Gál Péter</dc:creator>
      <pubDate>Thu, 08 Jul 2021 21:05:03 +0000</pubDate>
      <link>https://dev.to/wault/wault-the-future-of-password-storage-e3j</link>
      <guid>https://dev.to/wault/wault-the-future-of-password-storage-e3j</guid>
      <description>&lt;p&gt;Password managers are becoming more common these days as we are using an increasing number of sites each day. I have used several password managers for about 4 years, but I've never found the one that fits me. Everyone had some major flaws like it felt outdated or it was too expensive. Then it hit me... why shouldn't I create the next Facebook of password storage?&lt;/p&gt;

&lt;h3&gt;
  
  
  What were the main goals of the project?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. The app must have a generous free tier.&lt;/strong&gt; I wanted a personal plan, where you can store your passwords safely across multiple devices without hassle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The app must feel new and responsive.&lt;/strong&gt; When I used Lastpass and Bitwarden I felt like I was using a slightly outdated piece of software. I think the best and easiest way to achieve this is by &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Be open-source.&lt;/strong&gt; I think this one is obvious. If you make an application open source, then it means that there is nothing to hide.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can this app compete? What can it give to users, that other managers can't?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. The password manager without passwords.&lt;/strong&gt; The most common security threat for an application is user exploitation. You can easily create a clone of the original website and start phishing for passwords. But when you have no you don't have a way to gain access to a user's account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Free for the people, paid for organizations.&lt;/strong&gt; I have been using WinRAR and I love the idea behind it. My take on this idea is to give the free plan the ability to create &lt;strong&gt;2 people&lt;/strong&gt; teams (I haven't seen any other password manager do this) and when you want to add more users, then you must pay for the excess number of people. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The ability to store crypto wallets.&lt;/strong&gt; I must admit: the crypto hype train got me too, but when you consider it, then it will look like a good idea. You can store crypto wallets in the application, check your balance, send and receive money. It is easy to implement and also it is unique for this application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Rich customization for secure notes.&lt;/strong&gt; I have been using Google Keep through my entire high school years, so I got used to it. But when I want to write a note in my Bitwarden Vault, I cannot format my text, nor can I create a checklist, so it is not convenient enough for everyday use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Zero trackings.&lt;/strong&gt; A password manager must be a private space. You don't want to be tracked when you are managing confidential information. &lt;/p&gt;

&lt;h3&gt;
  
  
  Want to help?
&lt;/h3&gt;

&lt;p&gt;The project is already in a very early stage of development (as the application is only good enough to log in on the web interface), but any contribution is welcome.&lt;/p&gt;

&lt;p&gt;Github organization: &lt;a href="https://github.com/wault-app"&gt;github.com/wault-app&lt;/a&gt;&lt;br&gt;
Discord: &lt;a href="https://discord.gg/NxhdAf4azz"&gt;discord.gg/NxhdAf4azz&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>nextjs</category>
      <category>typescript</category>
      <category>security</category>
    </item>
    <item>
      <title>4 reasons to use NextJS</title>
      <dc:creator>Gál Péter</dc:creator>
      <pubDate>Fri, 18 Sep 2020 22:30:09 +0000</pubDate>
      <link>https://dev.to/pepyta/4-reasons-to-use-nextjs-3294</link>
      <guid>https://dev.to/pepyta/4-reasons-to-use-nextjs-3294</guid>
      <description>&lt;p&gt;At first I was scared to use JavaScript libraries, but then I tried them out and it kinda felt right. I was drawn by this world. It really made my days a lot simpler and me a better developer.&lt;/p&gt;

&lt;h3&gt;
  
  
  But before I begin. What is NextJS?
&lt;/h3&gt;

&lt;p&gt;NextJS is a javascript library that uses React to help you develop better applications. It manages both your API endpoints and your static or server-sde rendered pages. So it's kind of neat.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/vercel" rel="noopener noreferrer"&gt;
        vercel
      &lt;/a&gt; / &lt;a href="https://github.com/vercel/next.js" rel="noopener noreferrer"&gt;
        next.js
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      The React Framework
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
  &lt;a href="https://nextjs.org" rel="nofollow noopener noreferrer"&gt;
    
      
      &lt;img alt="Next.js logo" src="https://camo.githubusercontent.com/26d06a6572aa5d9ecdb699add71d40e57aefe8244c6306ba58a70aee6ad5123c/68747470733a2f2f6173736574732e76657263656c2e636f6d2f696d6167652f75706c6f61642f76313636323133303535392f6e6578746a732f49636f6e5f6c696768745f6261636b67726f756e642e706e67" height="128"&gt;
    
  &lt;/a&gt;
  &lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Next.js&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://vercel.com" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Vercel logo" src="https://camo.githubusercontent.com/a7ee01bcc96a6e07e392a87f7e3202faa847efd0bc129e66f716ea98d9302ced/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d414445253230425925323056657263656c2d3030303030302e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d56657263656c266c6162656c436f6c6f723d303030"&gt;&lt;/a&gt;
&lt;a href="https://www.npmjs.com/package/next" rel="nofollow noopener noreferrer"&gt;&lt;img alt="NPM version" src="https://camo.githubusercontent.com/60dcf9db176916c5e18b23978eb6d1c0282a88ed3d9632568c6b953f868b3b6f/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6e6578742e7376673f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d303030303030"&gt;&lt;/a&gt;
&lt;a href="https://github.com/vercel/next.js/blob/canary/license.md" rel="noopener noreferrer"&gt;&lt;img alt="License" src="https://camo.githubusercontent.com/34bfded824851462f4cbaf614527b184b1872b41e35a6414ecbff72ecbe1e25a/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f6e6578742e7376673f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d303030303030"&gt;&lt;/a&gt;
&lt;a href="https://github.com/vercel/next.js/discussions" rel="noopener noreferrer"&gt;&lt;img alt="Join the community on GitHub" src="https://camo.githubusercontent.com/84f18bb62460515b8c657f349c87d7f8a85b6044b58e73495f4dbe79588f59c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4a6f696e253230746865253230636f6d6d756e6974792d626c756576696f6c65742e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d4e6578742e6a73266c6162656c436f6c6f723d303030303030266c6f676f57696474683d3230"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Getting Started&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Used by some of the world's largest companies, Next.js enables you to create full-stack web applications by extending the latest React features, and integrating powerful Rust-based JavaScript tooling for the fastest builds.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Visit our &lt;a href="https://nextjs.org/learn" rel="nofollow noopener noreferrer"&gt;Learn Next.js&lt;/a&gt; course to get started with Next.js.&lt;/li&gt;
&lt;li&gt;Visit the &lt;a href="https://nextjs.org/showcase" rel="nofollow noopener noreferrer"&gt;Next.js Showcase&lt;/a&gt; to see more sites built with Next.js.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Documentation&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Visit &lt;a href="https://nextjs.org/docs" rel="nofollow noopener noreferrer"&gt;https://nextjs.org/docs&lt;/a&gt; to view the full documentation.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Community&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;The Next.js community can be found on &lt;a href="https://github.com/vercel/next.js/discussions" rel="noopener noreferrer"&gt;GitHub Discussions&lt;/a&gt; where you can ask questions, voice ideas, and share your projects with other people.&lt;/p&gt;
&lt;p&gt;To chat with other community members you can join the Next.js &lt;a href="https://nextjs.org/discord" rel="nofollow noopener noreferrer"&gt;Discord&lt;/a&gt; server.&lt;/p&gt;
&lt;p&gt;Do note that our &lt;a href="https://github.com/vercel/next.js/blob/canary/CODE_OF_CONDUCT.md" rel="noopener noreferrer"&gt;Code of Conduct&lt;/a&gt; applies to all Next.js community channels. Users are &lt;strong&gt;highly encouraged&lt;/strong&gt; to read and adhere to them to avoid repercussions.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Contributing&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Contributions to Next.js are welcome and highly appreciated. However, before you jump right into it, we would like you to review our…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/vercel/next.js" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  1. It will create a faster and lighter website
&lt;/h3&gt;

&lt;p&gt;When it comes to creating a website, writing it only in HTML is not just hard and time consuming, but you probably can't write a better code than what a computer can generate (at least in terms of package size).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The framework will handle bundling better than anything else. If you have funcntions/classes that you don't use it will just simply&lt;br&gt;
 leave it out.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you were to write a basic site with HTML/CSS/JS you would have to remove every unused code to not bloat the users' networks.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. You can use &lt;em&gt;almost&lt;/em&gt; any NPM package
&lt;/h3&gt;

&lt;p&gt;For sure there is browserify and webpack by themselves that can handle this task, but they will generate files that are going to include things that you don't need. If you have multiple packages, you will know that your &lt;code&gt;node_modules&lt;/code&gt; folder is weighing several mb of data. If you want to send them every time someone wants to access your site you are going to face slow loading times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contary to the NextJS, it will handle everything and you can use any NPM package, that can run in a browser, let's just say it is &lt;code&gt;timsort&lt;/code&gt; or &lt;code&gt;material-ui&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. You're going to have clean developement envoriments
&lt;/h3&gt;

&lt;p&gt;You have &lt;code&gt;import&lt;/code&gt;s and the support of &lt;code&gt;typescript&lt;/code&gt; (which means that you will have typings and classes &lt;em&gt;thanks God&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;I can't stress this enough. You're not really writing pages, but rather you're writing independent &lt;code&gt;Component&lt;/code&gt;s, that look much cleaner that their predecessor.&lt;/p&gt;

&lt;p&gt;Also being able to tell if your variable is a &lt;code&gt;string&lt;/code&gt; or a &lt;code&gt;number&lt;/code&gt; or if it has &lt;code&gt;username&lt;/code&gt; component or not will make your everyday life much better. Trust me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shortly, you're going to have typings, which means autocomplete for your code and code splitting, which is good if you're building large applications&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. You're going to have a large community, that can help you
&lt;/h3&gt;

&lt;p&gt;When I first started to use React, I felt that it was so easy, because there were so good documentations. And not just that, you don't even have to worry about creating every single UI components. You have multiple implementations of Material Design Principles. If you don't trust me than just think about that the largest JS framework is React. We can use React components, so I think we kind of have a head start, compared to other frameworks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Great! How can I jump in?
&lt;/h3&gt;

&lt;p&gt;With the release of &lt;code&gt;create-next-app&lt;/code&gt;, it is easier to start creating a project than ever. If you want to jump right in, then after you've installed NodeJS, you just have to run the &lt;code&gt;npx create-next-app&lt;/code&gt; command and your project is ready to edit it. &lt;/p&gt;

&lt;h3&gt;
  
  
  Can you give me some advice?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use TypeScript!&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://material-ui.com/" rel="noopener noreferrer"&gt;&lt;code&gt;material-ui&lt;/code&gt;&lt;/a&gt; to create User Interfeces&lt;/li&gt;
&lt;li&gt;Have a folder structure that has (/pages, /public, /components) folders.&lt;/li&gt;
&lt;li&gt;If you're developing an API use &lt;a href="https://prisma.io" rel="noopener noreferrer"&gt;Prisma&lt;/a&gt;. It is a database driver, that will generate a type-safe JS module for you to use it in your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for your attention!&lt;br&gt;
Gál Péter (&lt;a href="https://github.com/pepyta" rel="noopener noreferrer"&gt;pepyta&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
