<?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: Ankur Rohilla</title>
    <description>The latest articles on DEV Community by Ankur Rohilla (@ankurlakhmara).</description>
    <link>https://dev.to/ankurlakhmara</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%2F473831%2F76f262ea-40af-4295-96e9-2980b7578e20.png</url>
      <title>DEV Community: Ankur Rohilla</title>
      <link>https://dev.to/ankurlakhmara</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankurlakhmara"/>
    <language>en</language>
    <item>
      <title>Base 64 Encoder-Decoder in Java</title>
      <dc:creator>Ankur Rohilla</dc:creator>
      <pubDate>Thu, 26 Aug 2021 08:35:33 +0000</pubDate>
      <link>https://dev.to/ankurlakhmara/base-64-encoder-decoder-in-java-23b2</link>
      <guid>https://dev.to/ankurlakhmara/base-64-encoder-decoder-in-java-23b2</guid>
      <description>&lt;p&gt;Encoding is a way to encode anything as it is, without any line separation. Where output generated is the character set A-Za-z0–9+/, and the decoder rejects any characters outside of that set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Encoding
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Scanner&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Scanner&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;in&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;nextLine&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;encodeInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getEncoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;encodeToString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getBytes&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;StandardCharsets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;UTF_8&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Encoded output is :"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;encodeInput&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Example if we give input &lt;em&gt;"hey ankur"&lt;/em&gt;&lt;br&gt;
Then the output will be : &lt;em&gt;aGV5IGFua3Vy&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Decoding
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;        &lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getDecoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;decode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encodeInput&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;decodeOutput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"The decoded output is :"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;decodeOutput&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we gives the same output that is encoded by the base-64 encoder as we write above then the output we will get :&lt;br&gt;
is &lt;em&gt;"hey ankur"&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Base 64 Encoding Works?
&lt;/h2&gt;

&lt;p&gt;Base64 encoding is used when any binary data needs to be transmitted over a media that is designed to handle only textual data. Many communication protocols like SMTP, NNTP were traditionally designed to work with plain text data represented by the 7-bit US-ASCII character set. To transfer non-ASCII or binary data over such communication channels, the binary data is encoded to the ASCII charset using Base64 encoding scheme.&lt;/p&gt;

&lt;p&gt;The encoding process converts binary data to a printable ASCII string format. The decoding process converts the encoded string back to binary data. for detailed information &lt;a href="https://www.base64decoder.io/learn/#:~:text=The%20encoding%20process%20converts%20binary,%2B%20%2C%20%2F%20%2C%20and%20%3D%20."&gt;click here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Complete java program for Encoding and Decoding using Base 64
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;Basic_project&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.nio.charset.StandardCharsets&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.Base64&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.Scanner&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;encoder_decoder&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;){&lt;/span&gt;
        &lt;span class="nc"&gt;Scanner&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Scanner&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;in&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;nextLine&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;encodeInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getEncoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;encodeToString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getBytes&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;StandardCharsets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;UTF_8&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Encoded output is :"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;encodeInput&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Base64&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getDecoder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;decode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encodeInput&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;decodeOutput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"The decoded output is :"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;decodeOutput&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>encoding</category>
      <category>decoding</category>
      <category>base64</category>
    </item>
    <item>
      <title>RSA &amp; How to Create encryption key?</title>
      <dc:creator>Ankur Rohilla</dc:creator>
      <pubDate>Sat, 24 Oct 2020 13:44:33 +0000</pubDate>
      <link>https://dev.to/ankurlakhmara/rsa-how-to-create-encryption-key-3bkd</link>
      <guid>https://dev.to/ankurlakhmara/rsa-how-to-create-encryption-key-3bkd</guid>
      <description>&lt;p&gt;&lt;strong&gt;RSA&lt;/strong&gt; (Rivest–Shamir–Adleman) is a public-key cryptosystem that is widely used for secure data transmission.&lt;br&gt;
RSA method is a widely used encryption algorithm. You cannot discuss cryptography without at least some discussion of RSA. This public key method was &lt;strong&gt;developed in 1977 by three mathematicians: Ron Rivest, Adi Shamir, and Len Adleman.&lt;/strong&gt; The name RSA is derived from the first letter of each mathematician’s last name. One significant advantage of RSA is that it is a public key encryption method. That means there are no concerns with distributing the keys for the encryption. However, RSA is much slower than symmetric ciphers. In fact, in general, asymmetric ciphers are slower than symmetric ciphers. &lt;/p&gt;

&lt;p&gt;The steps to create the key are as follow :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate two large random primes, p and q, of approximately equal size. &lt;/li&gt;
&lt;li&gt;Pick two numbers so that when they are multiplied together the product will be the size you want (that is, 2048 bits, 4096 bits, etc.). &lt;/li&gt;
&lt;li&gt;Now multiply p and q to get n. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Let n = pq.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Multiply Euler’s totient for each of these primes. If you are not familiar with this concept, the Euler’s Totient is the total number of coprime numbers. Two numbers are considered co-prime if they have no common factors. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, if the original number is 7, then 5 and 7 would be coprime. It just so happens that for prime numbers, this is always the number minus 1. For example, 7 has 6 numbers that are co-prime to it (if you think about this a bit you will see that 1, 2, 3, 4, 5, 6 are all coprime with 7).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Let m = (p – 1)(q – 1).&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select another number; call this number &lt;strong&gt;e&lt;/strong&gt;. You want to pick e so that it is &lt;strong&gt;co-prime to m.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find a number d that when multiplied by e and modulo m would yield 1. (Note: Modulo means to divide two numbers and return the remainder. For example, 8 modulo 3 would be 2.) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find &lt;strong&gt;d&lt;/strong&gt;, such that &lt;strong&gt;de mod m ≡ 1.&lt;/strong&gt; Now you publish &lt;strong&gt;e&lt;/strong&gt; and &lt;strong&gt;n&lt;/strong&gt; as the public key and keep &lt;strong&gt;d&lt;/strong&gt; and &lt;strong&gt;n&lt;/strong&gt; as the secret key.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To encrypt you simply take your message raised to the e power and modulo &lt;br&gt;
&lt;strong&gt;n = Me % n&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;To decrypt you take the ciphertext, and raise it to the d power modulo &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;n: P = Cd % n&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;RSA has become a popular encryption method. It is considered quite secure and is often used in situations where a high level of security is needed.&lt;/p&gt;

</description>
      <category>security</category>
      <category>rsa</category>
      <category>cryptography</category>
      <category>datatransmission</category>
    </item>
    <item>
      <title>What is the Firewall?</title>
      <dc:creator>Ankur Rohilla</dc:creator>
      <pubDate>Sun, 11 Oct 2020 08:15:47 +0000</pubDate>
      <link>https://dev.to/ankurlakhmara/what-is-the-firewall-38nd</link>
      <guid>https://dev.to/ankurlakhmara/what-is-the-firewall-38nd</guid>
      <description>&lt;p&gt;A firewall is a guard b/w your computer or your internal network and the outside world or the Internet. A particular firewall implementation may use one or more these types of methods :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Packet filtering &lt;/li&gt;
&lt;li&gt;Stateful packet filtering &lt;/li&gt;
&lt;li&gt;User authentication &lt;/li&gt;
&lt;li&gt;Client application authentication&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A firewall will filter incoming packets based upon these parameters such as packet size, source IP address, protocol, and destination port. Linux and Windows operating systems come up with a simple firewall. There are two best personal firewall solution provider for individual PCs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Norton&lt;/li&gt;
&lt;li&gt;McAfee&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These firewalls are meant for individual machines. There are many advanced solutions available for network protection.&lt;br&gt;
In an organizational setting, you can establish a dedicated firewall b/w your network and the outside world. This may be a router that also has built-in firewall capabilities. (Cisco Systems is one company that is well-known for high-quality routers and firewalls.) Alternatively, it might be a server that is dedicated to run firewall software. There are many numbers of firewall solutions that you can examine.&lt;/p&gt;

</description>
      <category>security</category>
      <category>internet</category>
      <category>firewall</category>
    </item>
  </channel>
</rss>
