C# Public/Private Key Encryption using Visual Studio 2019 | RSA Cryptography

Sdílet
Vložit
  • čas přidán 8. 04. 2021
  • C# Public/Private Key Encryption using Visual Studio 2019 | RSA Cryptography
    C# PUBLIC/PRIVATE KEY ENCRYPTION
    C# and .Net provides implementations of many standard cryptographic algorithms.
    RSA being a public key crypto-system has two keys, the Public key and the Private key. The Encryption is done using one and the decryption is done using the other. Normally, the encryption is done using the Public key and the decryption is done using the Private key. The RSA modulus (explained below) length is called the key length of the cipher. The currently largest factored prime number had 768 bit. As the security of RSA depends on the factoring problem, using a modulus of 1024 bits is a bare minimum. It is recommended to use at least 2048 bits for good security. 4096 bit is pretty much unbreakable, anything beyond 4096 bits is over the top and would also be painfully slow. #selfhostwcf, #p2pnetworkprogramming,#netcorecommerce
  • Věda a technologie

Komentáře • 85

  • @felipeayon4239
    @felipeayon4239 Před 3 lety +2

    Oh man! thanks for that ! im suscribing right away!
    Cheers from Mexico city!

  • @nicholasberglund
    @nicholasberglund Před 2 lety

    Excellent video! Thank you!

  • @gibbytravis
    @gibbytravis Před 2 lety +3

    How do you specify or generate the keys though? It doesn't seem very useful if everyone uses the same keys.

  • @hexrat8692
    @hexrat8692 Před 3 lety

    dude best timing i love you

  • @ScottSmithPiano
    @ScottSmithPiano Před 2 lety

    Great stuff! Now I just need to figure out where to store my Public and Private RSA keys

  • @tonyriddle7646
    @tonyriddle7646 Před 3 lety +1

    and why csp intantiated in encrypt() and not in decrypt()??

  • @danbarry3678
    @danbarry3678 Před 2 lety

    I'm trying to figure out how I would use this with an existing RSA 4096 key? Excellent video... !!

  • @ifzen77
    @ifzen77 Před 2 lety +3

    Hi Hacked :) Thanks a lot for this very clear exposé. One question though, you create an instance of csp static property initialised at creation but you do an other new() for it in the Encrypt() method. Is it necessary to do so or the new() in the property definition is enough ?

    • @hacked101
      @hacked101  Před 2 lety

      Hi bud, thanks for the comment, will have a look and get back ASAP

    • @plaguerat6471
      @plaguerat6471 Před 11 měsíci +6

      legend has it he never got back

  • @ravebrave8866
    @ravebrave8866 Před rokem

    I just came across this video looking how to decrypt the files.. my computer got ransome ware.. online key decryption is that possible.. please help

  • @GiorgiBekurashvili
    @GiorgiBekurashvili Před 8 měsíci

    Thank you very much!

  • @avneeshgupta4388
    @avneeshgupta4388 Před 2 lety

    Bro I have an encrypted videos AES encryption , you have any software to decrypt then please share I need help

  • @kevinguzman3796
    @kevinguzman3796 Před 2 lety

    excellent video helped me a lot

  • @user-pt5qr5yk8z
    @user-pt5qr5yk8z Před 5 měsíci

    Thank you so much!

  • @tonyriddle7646
    @tonyriddle7646 Před 3 lety

    why false in Encrypt() and decrypt() ?

  • @heischono4917
    @heischono4917 Před 2 lety +1

    Hi Hacked :) This is the first video I saw from you, thank you! In my case, i have a Windows Service, communicating directly with a Server (without any GUI), where credentials are saved. In your example you have one single class, where both private and public key are stored. But I need a variant, where the public key is on the server, while the private key is only accessible in the Windows Service. Perhaps, the class may not store the private key, but send the key to the Windows Server? What is the most secure way to transfer the private key, without decreasing security? Btw. the communication between the Windows Service and the Server will be by gRPC.

    • @hacked101
      @hacked101  Před 2 lety +1

      You can make it a base class, and create both classes for public and private keys derived from the base class

  • @anujadi8366
    @anujadi8366 Před rokem

    Thanks a lot great explanation

  • @_STF2023_the_camera.kinemaster

    Thanks man about it. Rarely I have found explanation about this at CZcams. Do you have course at udemy about it? Where you setup to sha256 for example? Could I use JWT and Identity Model token to generate this?
    Greetings from Brazil

    • @hacked101
      @hacked101  Před 3 lety +1

      You are welcome, no I don't have courses on udemy

  • @TheHitchenator
    @TheHitchenator Před 2 lety

    Love it. Follow-up question for me is what if I need to decrypt some data at a later date - for instance after closing and reopening the program or restarting the machine it's running on?
    How does one safely store the private key for use at a later date?

    • @hacked101
      @hacked101  Před 2 lety

      You have to save the generated keys then

    • @TheHitchenator
      @TheHitchenator Před 2 lety

      @@hacked101 do... do I encrypt the private key when saving it? Surely it defeats the purpose if stored in plaintext?

  • @ChaosMind95
    @ChaosMind95 Před 2 lety +1

    Hi Hacked, thank you for the videos it's really helpful, I have a question tho .. how can I load and use my public and private keys in XML format instead of the generated ones ?

    • @hacked101
      @hacked101  Před 2 lety +2

      I will make a video on that shortly

    • @sarc007
      @sarc007 Před rokem

      Hi @Hacked I just want to use my custom public key (which is string passed as parameter to my application) how do I use that

    • @sarc007
      @sarc007 Před rokem

      Hi @@hacked101 I just want to use my custom public key (which is string passed as parameter to my application) how do I use that

  • @JarppaGuru
    @JarppaGuru Před 2 lety

    do we need write all this again to just see it wont work.
    where it get those private and public keys. where i find my public key so someone can encode message for me lol
    what xml. not even opened any xml lol

  • @Patwal77
    @Patwal77 Před 3 lety

    Do we have ECDH support in .Net ..I looked around coudnt find any library

    • @hacked101
      @hacked101  Před 3 lety

      Will look into that shortly thanks

  • @0109004501
    @0109004501 Před 2 lety

    thank you for the videos it's really helpful, but how can I load and use my public instead of generate it in order to encrypt data

    • @hacked101
      @hacked101  Před 2 lety

      You are welcome, will make a video on that shortly

  • @mckzik1983
    @mckzik1983 Před 10 měsíci

    how to load a saved key?

  • @yangarea8174
    @yangarea8174 Před 3 lety

    Nice video

  • @mohammadkhalafIraqi
    @mohammadkhalafIraqi Před rokem

    thanks 🙏

  • @Gr4ceMt
    @Gr4ceMt Před 3 lety

    Sorry, for a stupid question. Can I adapt this to API ?

    • @hacked101
      @hacked101  Před 3 lety

      Don't really get you, but if what I'm getting is true, then yes you can

  • @kalemabashiribrahim1911
    @kalemabashiribrahim1911 Před 9 měsíci

    Hi Hacked.. thanks for the video
    In case i want to use the keys have generated using Keystore Explorer.. How can i apply the same concept

  • @sage_x2002
    @sage_x2002 Před 2 lety +3

    Outputting both keys to string reveals that both are identical. Private key = public key, that therefore doesn't work as intended as you could share the public key with anyone and someone else would be able to decrypt it using the public key.
    To proof that, I also changed the export parameters and encrypted and decrypted using the public key and the private key.
    This should work by encrypting using the public key and decrypting using the private key ONLY.

    • @afonsomariapereiramateus5711
      @afonsomariapereiramateus5711 Před 9 měsíci

      Hello, I really need some help understading what you've written above. can you explain how the two keys are equal?

  • @arminafshani5754
    @arminafshani5754 Před rokem

    i get error for text > 58 character length
    what i do to fix that ?
    error :An unhandled exception of type
    line error : var cypher = csp.Encrypt(data, false); // encrypt function

  • @marwarajab7375
    @marwarajab7375 Před rokem

    How can I create a project with a button to fetch a file and display its path in a textbox, another button to encrypt the file in disk D and calculate the encoding time for the file and put it in a textbox, and a third button to decrypt the file and calculate the decoding time for the file and put it in a textbox using RSA algorithm in C# and return The file after decoding to the same type as the original file?

    • @hacked101
      @hacked101  Před rokem

      Watch my video on encryption

    • @marwarajab7375
      @marwarajab7375 Před rokem

      I watched the video, but I want to encrypt any file inside the computer by specifying its path in the botton, calling the path by the RSA algorithm, who has been decrypted, and calculating the time of encryption and decryption. Can you help me?

  • @toface5872
    @toface5872 Před 3 lety

    dude i just gonna say Prefecto,
    Since you "Hackd Bytes" Right, You Can make video for Self Modifying Code (Encrypt Memory At Runtime) using C# console, nice idea.

    • @hacked101
      @hacked101  Před 3 lety

      No doubt, will look into that shortly

  • @jasonszsilva3489
    @jasonszsilva3489 Před 9 měsíci

    how to do this in python

  • @darklevi7
    @darklevi7 Před 8 měsíci

    there is an error in decrypting the cipher !! why ?
    i followed the steps correctly.

    • @hacked101
      @hacked101  Před 8 měsíci +1

      You are probably missing something, please have a look properly. Otherwise you can become a member for more support thanks

    • @darklevi7
      @darklevi7 Před 8 měsíci

      @@hacked101 thanks bro , I fixed it. It was the constructor

    • @hacked101
      @hacked101  Před 8 měsíci +1

      @@darklevi7 you are welcome

  • @larafreitas8155
    @larafreitas8155 Před 2 lety

    Hi how could i do the same but for a file??

    • @hacked101
      @hacked101  Před 2 lety

      Check out the channel I have a for that thanks

  • @user-eeindor35
    @user-eeindor35 Před 9 měsíci

    hi Hacker, why not publish the code of this example?

    • @hacked101
      @hacked101  Před 9 měsíci

      I make the source available to channel members

  • @xrealim
    @xrealim Před 3 lety

    this good work but
    i need encrypt my source |.cs file| Self-Crypt --how
    and i need encrypt memory my program like values bytes change in memory Repeatedly and change UTF-8 String To another way -how
    and Execute orders or commands and clear Memory Automatic --how
    All of this in C# Language not c++ or c (JUST-ONE-WORD : HOW)
    Question Remains : Is C# supported for this
    I hope to give me Way to do this.

    • @hacked101
      @hacked101  Před 3 lety

      If you want to encrypt a file, check out the channel, I have a video on that in C#

    • @xrealim
      @xrealim Před 3 lety

      bro you don't understand me
      i mean i want encrypt my program memory my process ,you get.

    • @hacked101
      @hacked101  Před 3 lety

      Check this playlist: czcams.com/play/PLXLkA7FAishrJVKN82KL87Ni7WsRJ6OhX.html

  • @ramakrishnaboyapati9930
    @ramakrishnaboyapati9930 Před 8 měsíci

    Thank you very much brother. I have followed your code and it is working fine. I have written all the code by creating console application in my pc. It has worked as it is. I am so happy. But, I have a doubt. We are a spiritual organisation and asked our bank to give api to check our bank account details. they have given api and they asked for public key certificate. I have generated a certificate and give them. So, how to use that certificate to do the encryption. Please give me any your youtube link for this.

  • @emanuelcordovamontiel1017
    @emanuelcordovamontiel1017 Před 9 měsíci

    Can I use a private key (.key)?

  • @freelancewebdeveloper3073

    Please make more videos on Android xamarin

  • @arminafshani5754
    @arminafshani5754 Před rokem

    how to encrypted file ?

    • @hacked101
      @hacked101  Před rokem

      Check out the channel I have a video on that

  • @Dazza_Doo
    @Dazza_Doo Před rokem