{"id":78796,"date":"2021-12-01T23:37:06","date_gmt":"2021-12-01T23:37:06","guid":{"rendered":"https:\/\/papersspot.com\/blog\/2021\/12\/01\/project-submission-following-is-required-for-final-project-source-code-of-any\/"},"modified":"2021-12-01T23:37:06","modified_gmt":"2021-12-01T23:37:06","slug":"project-submission-following-is-required-for-final-project-source-code-of-any","status":"publish","type":"post","link":"https:\/\/papersspot.com\/blog\/2021\/12\/01\/project-submission-following-is-required-for-final-project-source-code-of-any\/","title":{"rendered":"Project Submission: Following is required for Final Project Source code of any"},"content":{"rendered":"<p>Project Submission:<\/p>\n<p> Following is required for Final Project <\/p>\n<p> Source code of any cryptographic Algorithm RSA. <\/p>\n<p> Source code should contain following operations<\/p>\n<p> a. Key Generation<\/p>\n<p> b. Data (Alphanumeric) Encryption <\/p>\n<p> c. Data (Alphanumeric) Decryption<\/p>\n<p> This part done by me <\/p>\n<p> Project Report with <\/p>\n<p> a. Introduction of the project work<\/p>\n<p> b. Complete details of the Project Cryptographic Algorithm ( RSA ) <\/p>\n<p> c. Source Code <\/p>\n<p> import java.util.*;<\/p>\n<p> import java.lang.*;<\/p>\n<p> import java.io.*;<\/p>\n<p> import java.math.*;<\/p>\n<p> class RsaAlgorithm {<\/p>\n<p> public Random r;<\/p>\n<p> public int bitlength = 1024;<\/p>\n<p> public BigInteger p;<\/p>\n<p> public BigInteger q;<\/p>\n<p> public BigInteger N;<\/p>\n<p> public BigInteger phi;<\/p>\n<p> public BigInteger e;<\/p>\n<p> public BigInteger d;<\/p>\n<p> public static String bytesToString(byte[] encryptedString) {<\/p>\n<p> String test = &#8220;&#8221;;<\/p>\n<p> for (byte b : encryptedString) {<\/p>\n<p> test += Byte.toString(b);<\/p>\n<p> }<\/p>\n<p> return test;<\/p>\n<p> }<\/p>\n<p> \/\/ encrypting the message<\/p>\n<p> public byte[] encryption(byte[] message) {<\/p>\n<p> return (new BigInteger(message)).modPow(e, N).toByteArray();<\/p>\n<p> }<\/p>\n<p> \/\/ decrypting the message<\/p>\n<p> public byte[] decryption(byte[] message) {<\/p>\n<p> return (new BigInteger(message)).modPow(d, N).toByteArray();<\/p>\n<p> }<\/p>\n<p> public RsaAlgorithm() {<\/p>\n<p> r = new Random();<\/p>\n<p> p = BigInteger.probablePrime(bitlength, r);<\/p>\n<p> q = BigInteger.probablePrime(bitlength, r);<\/p>\n<p> N = p.multiply(q);<\/p>\n<p> phi = p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE));<\/p>\n<p> e = BigInteger.probablePrime(bitlength \/ 2, r);<\/p>\n<p> while (phi.gcd(e).compareTo(BigInteger.ONE) &gt; 0 &amp;&amp; e.compareTo(phi) &lt; 0) {<\/p>\n<p> e.add(BigInteger.ONE);<\/p>\n<p> }<\/p>\n<p> d = e.modInverse(phi);<\/p>\n<p> }<\/p>\n<p> public RsaAlgorithm(BigInteger e, BigInteger d, BigInteger N) {<\/p>\n<p> this.e = e;<\/p>\n<p> this.d = d;<\/p>\n<p> this.N = N;<\/p>\n<p> }<\/p>\n<p> @SuppressWarnings(&#8220;deprecation&#8221;)<\/p>\n<p> public static void main(String[] args) throws java.lang.Exception {<\/p>\n<p> String inp;<\/p>\n<p> DataInputStream in = new DataInputStream(System.in);<\/p>\n<p> RsaAlgorithm rsa = new RsaAlgorithm();<\/p>\n<p> System.out.println(&#8220;Salem Alhosani &#8211; A00049893 (RSA)&#8221;);<\/p>\n<p> System.out.println(&#8220;Enter the private Message:&#8221;);<\/p>\n<p> inp = in.readLine();<\/p>\n<p> System.out.println(&#8220;Encrypting the given String: &#8221; + inp);<\/p>\n<p> System.out.println(&#8220;String in Bytes: &#8221; + bytesToString(inp.getBytes()));<\/p>\n<p> \/\/ encryption is performed first<\/p>\n<p> byte[] encryptedString = rsa.encryption(inp.getBytes());<\/p>\n<p> \/\/ decryption<\/p>\n<p> \/\/ at second stage<\/p>\n<p> byte[] decryptedString = rsa.decryption(encryptedString);<\/p>\n<p> System.out.println(&#8220;Decrypting Bytes: &#8221; + bytesToString(decryptedString));<\/p>\n<p> System.out.println(&#8220;Decrypted String recieved : &#8221; + new String(decryptedString));<\/p>\n<p> }<\/p>\n<p> }<\/p>\n<p> d. Screen shots of code execution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project Submission: Following is required for Final Project Source code of any cryptographic Algorithm RSA. Source code should contain following operations a. Key Generation b. Data (Alphanumeric) Encryption c. Data (Alphanumeric) Decryption This part done by me Project Report with a. Introduction of the project work b. Complete details of the Project Cryptographic Algorithm ( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10],"class_list":["post-78796","post","type-post","status-publish","format-standard","hentry","category-research-paper-writing","tag-writing"],"_links":{"self":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/78796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/comments?post=78796"}],"version-history":[{"count":0,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/posts\/78796\/revisions"}],"wp:attachment":[{"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/media?parent=78796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/categories?post=78796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/papersspot.com\/blog\/wp-json\/wp\/v2\/tags?post=78796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}