?
Solved

C# ... Encryption & decryption RSA 2048

Posted on 2016-10-27
4
Medium Priority
?
59 Views
Last Modified: 2016-11-16
#Encryption & decryption RSA 2048
Hi ,
I want to encrypt the text typed by user from text box and then encrypt that text by using public key  and save to db as cypher text. at that time private key to decrypt that cypher text has been generated at the same time. that generated private key is the only one that can decrypt the text .... later I retrive that cypher text from another page and need to decrypt that cypher text to original text using private key ... in this case ..., Where can I get the private key at that time.. and how can I do... anyone help me... pls thanks ... It means encryption and decryption is not occured at the same time...
0
Comment
Question by:Coral Coder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Paweł earned 1000 total points (awarded by participants)
ID: 41862033
Lets start with the idea of asymmetric encryption, in short a user generates two keys a public and a private one. Just as the names suggest you share the public one and keep the private one a secrete. the idea is that you encrypt with the public key, and de-crypt with the private key. that being said when you generate the two keys you would at that time store the private one in a super secrete location to use it for decryption later.

now I'm not 100% sure if you're using webforms, mvc, wpf, winrt, here's an example i made when i was exploring the topic for winrt

http://sharepoint-magic.blogspot.ch/2016/08/digital-signature-asymmetric-encryption.html

points of interest will be
  • GeneratePublicPrivateKeysForEncryption_Click
  • EncryptData_Click
  • Private_Decrypt_BTN_Click

as i recall there are different API's for winrt, so it may take some digging around by you, if you're not doing winRT i'd start at the following
https://msdn.microsoft.com/en-us/library/tswxhw92(v=vs.110).aspx
0
 
LVL 64

Assisted Solution

by:btan
btan earned 1000 total points (awarded by participants)
ID: 41862516
For encryption of the text, suggest you consider symmetric instead of asymmetric as it is mostly use for small size block like key string. If the user text string is going to long and probably it is then symmetric encryption will be optimal for performance.

The symmetric encryption in this case can be via a pseudo random generated secret that is used to encrypt the text and then this same secret can be encrypted by your public key. The ciphertext and encrypted key can be combined (concatenated) and stored in the db as required. The private key is used to decrypt the secret which then is used to decrypt the ciphertext. You may considered the use of  Data Protection API. https://msdn.microsoft.com/en-us/windows/uwp/security/data-protection
0
 
LVL 10

Expert Comment

by:Paweł
ID: 41863701
Btan is spot on, asymmetric encryption isn't well suited for encrypting large amounts of data. As he says a great use of asymmetric encryption would be to generate a symmetric key and exchange it via asymmetric encryption, below is a nice explanation of what we're talking about.

http://mypathtowinrtdev.blogspot.ch/2014/06/securely-transferring-data.html
0
 
LVL 64

Expert Comment

by:btan
ID: 41889422
As suggested.
0

Featured Post

Cyber Threats to Small Businesses (Part 2)

The evolving cybersecurity landscape presents SMBs with a host of new threats to their clients, their data, and their bottom line. In part 2 of this blog series, learn three quick processes Webroot’s CISO, Gary Hayslip, recommends to help small businesses beat modern threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question