{"id":25,"date":"2008-11-08T22:23:00","date_gmt":"2008-11-08T22:23:00","guid":{"rendered":"http:\/\/projects-sanil.co.cc\/ProjectsBlog\/post.aspx?id=b181ea16-8308-48c2-a347-1ce3338f0653"},"modified":"2008-11-08T22:23:00","modified_gmt":"2008-11-08T22:23:00","slug":"making-your-application-data-secure-in-net-by-rsa-encryption","status":"publish","type":"post","link":"https:\/\/inullable.in\/blog\/?p=25","title":{"rendered":"Making your application data secure in .NET by RSA encryption"},"content":{"rendered":"<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:af49e8d8-df68-46c3-9e16-33c17f41960c\" class=\"wlWriterSmartContent\" style=\"margin: 0px; display: inline; padding: 0px\">\nTechnorati Tags: <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/\"><\/a>\n<\/div>\n<p>\nBeing an web site owner, make your life S**k.&nbsp; Its not that, having a personal site is bad, its feel great, but maintaining it is the hard part. first you have to keep it looking cool, and somewhat secure enough that some maniac can&#39;t hack it (at least easily), besides other overheads of uploading your pages via FTP to web server.\n<\/p>\n<p>\nOne day, I was trying to upload the pages to an FTP, but damn the &quot;Trial version expired&quot; popped up. Since, I was f**ked up using trial and &quot;free&quot; wares. So, I decided to make my own FTP client in .net.\n<\/p>\n<p>\nThe among the initial problems, that I got across during development was making password and other data secure, for that I relied on encrypting data by RSA, and serializing it to a binary file. The .NET here comes to rescue (I didn&#39;t need to implement RSA).\n<\/p>\n<p>\nThe .NET framework provides the RSACryptoServiceProvider namespace that provides seamless RSA encryption and decryption functions.\n<\/p>\n<p>\nHere is how it goes:\n<\/p>\n<blockquote>\n<p>\n\tusing System.Security.Cryptography;\n\t<\/p>\n<\/blockquote>\n<blockquote>\n<p>\n\t<strong>RSACryptoServiceProvider RSCP = new RSACryptoServiceProvider();<\/strong>\n\t<\/p>\n<p>\n\t\/\/Encryption: Encrypts an normal byte[]\n\t<\/p>\n<p>\n\t<strong>Byte[] RSCP.Encrypt(Byte[] string, bool fOAEP)<\/strong>\n\t<\/p>\n<p>\n\t\/\/Decryption:Decrypts an encrypted byte[]\n\t<\/p>\n<p>\n\t<strong>Byte[] RSCP.Decrypt(Byte[] string, bool fOAEP)<\/strong>\n\t<\/p>\n<p>\n\tYou need to use same RSACryptoServiceProvider for encryption and decryption, so you will need to serialize the RSACryptoServiceProvider object to physical memory.\n\t<\/p>\n<p>\n\tRSACryptoServiceProvider provides 2 functions for this\n\t<\/p>\n<p>\n\tFor Binary (using Binary Formatter) serialization:\n\t<\/p>\n<p>\n\t<strong>RSCP.ExportCSPBlob(bool)<\/strong>\n\t<\/p>\n<p>\n\t<strong>RSCP.ImportCSPBlob(byte[])<\/strong>\n\t<\/p>\n<p>\n\tForm XML (Using Soap formatter) serialization:\n\t<\/p>\n<p>\n\t<strong>RSCP.ToXmlString(bool)<\/strong>\n\t<\/p>\n<p>\n\t<strong>RSCP.FromXmlString(string XMLString)<\/strong>\n\t<\/p>\n<\/blockquote>\n<p>\nTo use serialization you have to include following namespaces:\n<\/p>\n<p>\nSystem.Runtime.Serialization; <br \/>\nSystem.Runtime.Serialization.Formatters.Binary; <br \/>\nSystem.Runtime.Serialization.Formatters.Soap;\n<\/p>\n<p>\nthey allow you to save the serialize object to a file stream.\n<\/p>\n<p>\nSo, Secure computing made easy!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Technorati Tags: Being an web site owner, make your life S**k.&nbsp; Its not that, having a personal site is bad, its feel great, but maintaining it is the hard part. first you have to keep it looking cool, and somewhat secure enough that some maniac can&#39;t hack it (at least easily), besides other overheads of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,131],"tags":[],"_links":{"self":[{"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":0,"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"wp:attachment":[{"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inullable.in\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}