Asymmetric Encryption and Decryption in Node.js using RSA Public/Private Key Pairs

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024
  • #node-rsa #rsa #asymmetricencryption #piblicprivatekey
    Learn how to do encryption using public key and decryption using the private key in Nodejs
    This is a code walkthrough. to understand why and when to use RSA please watch the previous video in the playlist.
    Amazon Link: amzn.to/36pZN09
    Nodejs: nodejs.org/en/...
    npm package: www.npmjs.com/...
    Visual studio code: code.visualstu...
    Check out the playlist about RSA
    • RSA

ความคิดเห็น • 60

  • @SASA_maxillo
    @SASA_maxillo 3 หลายเดือนก่อน +1

    Bro i can't thank you enough, every video is useless except for yours, thank you.

  • @NhanNguyen-rh4lg
    @NhanNguyen-rh4lg 4 ปีที่แล้ว +3

    Perfect!!! You must be god and saving me Asymmetric, many thank!

    • @TechnoSaviour
      @TechnoSaviour  4 ปีที่แล้ว

      Thanks for your encouraging words 🙏

  • @MonicaloveNiallHoran
    @MonicaloveNiallHoran 2 ปีที่แล้ว

    Thank you! your video helped me to implement a pair of RSA keys encrypting-decrypting function in my code for my exam project, very useful and well-explained!

  • @12XFactor
    @12XFactor 3 ปีที่แล้ว

    That's good for the basics. To people who think about using exactly that solution, I would recommend not generate the keys one time and use them forever. Generate new keys for every package you want to send. The first information exchange will be the public keys of client and server and the second exchange round is transmitting the encrypted package. To make sure the package is not manipulated, extend the encryption with a signature.

  • @evendevilscry1431
    @evendevilscry1431 3 ปีที่แล้ว +1

    Nice video. Got so much to learn.. Thank you

  • @alejandrobermudez8799
    @alejandrobermudez8799 2 ปีที่แล้ว

    Very very useful information. Thank you very much.

  • @SwetavSavarn
    @SwetavSavarn 3 หลายเดือนก่อน

    I am quite confused in one thing .
    We are creating public and private key.
    And encrypting our string with that public key
    So if we are decrypting with private key how node-rsa specifiy that this private key is only used to decrypt the data not any other , as both public and private keys are independent not dependent to each other

  • @penguasaphonty8749
    @penguasaphonty8749 3 ปีที่แล้ว +1

    I can't run this in node js 8 version. Can you tell me how can I do the same thing in node js 8 version using crypto?

  • @gsiva3577
    @gsiva3577 29 วันที่ผ่านมา

    Super

  • @mohamedzemzemi1257
    @mohamedzemzemi1257 4 ปีที่แล้ว +2

    GG mate, thanks

  • @arun0686
    @arun0686 ปีที่แล้ว +1

    Hi im getting error like RSA PADDING CHECK PKCS1 OAEP ,OAEP DECODING ERROR ..help me

  • @snehasamuel7426
    @snehasamuel7426 11 หลายเดือนก่อน +1

    why cant i use the private key for encryption and public key for decryption

    • @SASA_maxillo
      @SASA_maxillo 3 หลายเดือนก่อน +2

      because the public key will travel through the internet but the private key can't, and a hacker can get the public key (because it is traveling though the internet) so when a hackers gets it, it's point less, because a public key can only encrypt and can't decrypt, so this is why RSA is a very safe way of transferring data

  • @abhishekpatel7624
    @abhishekpatel7624 2 ปีที่แล้ว

    How the sign and verify works in node-rsa? I implement at my local but all time give me false verify all tho plain text, and keys are everything correct but not sure what happened? Can you please explain?

  • @naumanshigri
    @naumanshigri 2 ปีที่แล้ว +1

    aju xheringmo.. very helpful

  • @okzowarz2275
    @okzowarz2275 5 หลายเดือนก่อน

    how can
    i use with client side

  • @rosalyna_24
    @rosalyna_24 3 ปีที่แล้ว +1

    hiii nice video but how can i use this module to encrypt a file that i'm going to send

    • @TechnoSaviour
      @TechnoSaviour  3 ปีที่แล้ว

      You can try converting the file to base64 string then encrypt it

  • @00WhiteDragon
    @00WhiteDragon 4 ปีที่แล้ว +1

    Nice vid.

  • @TrungNguyen-hx3ps
    @TrungNguyen-hx3ps 3 ปีที่แล้ว +1

    Hello, I need to convert a NodeJS function (using the crypto-js library) to PHP. I can pay for it. Can you do that?

    • @labiV1
      @labiV1 3 ปีที่แล้ว

      Yes I can do that. Is this job still available?

  • @t-pk
    @t-pk 4 ปีที่แล้ว +1

    thanks

  • @vipul8512
    @vipul8512 ปีที่แล้ว

    Can we use this in angular 12?

  • @adaadutv9426
    @adaadutv9426 4 ปีที่แล้ว +1

    Do you have example using asp.net core c#

    • @TechnoSaviour
      @TechnoSaviour  4 ปีที่แล้ว

      I'm planning to make one with a combination of Angular and .net core

  • @MrRiseful
    @MrRiseful 4 ปีที่แล้ว

    Like it!

  • @Unstoppable.Sakshi
    @Unstoppable.Sakshi ปีที่แล้ว +1

    Thank you for help .. But How I can apply this on my message in my project

  • @paymentpablo
    @paymentpablo ปีที่แล้ว

    Any tips for reading an encrypted message that is encrypted elsewhere? I have the private key and I tried importing the private key but it keeps giving me an error saying the private key is wrong?

    • @vanigarlapati7083
      @vanigarlapati7083 ปีที่แล้ว

      any luck? I am also working on the same requirement.

  • @matinzd
    @matinzd 2 ปีที่แล้ว +1

    You could just use built in crypto lib.

  • @anejatu1312
    @anejatu1312 3 ปีที่แล้ว

    can we use custom private key for decryption, how can i achieve it

    • @alejandrobermudez8799
      @alejandrobermudez8799 2 ปีที่แล้ว

      I try using a pair of keys (public an private) generated by the command "ssh-keygen -t rsa -b 4096 -a 100 -f mykey" and work very well. I hope it can be useful.

  • @andrewgad6746
    @andrewgad6746 4 ปีที่แล้ว

    Nice vid, you could have used a string literal 8:10

    • @TechnoSaviour
      @TechnoSaviour  4 ปีที่แล้ว

      Thanks, will use it for other videos

  • @anisulashik8836
    @anisulashik8836 2 ปีที่แล้ว

    can i use it in react js ??

    • @TechnoSaviour
      @TechnoSaviour  2 ปีที่แล้ว

      Yes, it’s a browser feature can be implemented in any language

  • @liveabhishekshukla
    @liveabhishekshukla 4 ปีที่แล้ว +1

    Please type fast.. video length will be small..

    • @TechnoSaviour
      @TechnoSaviour  4 ปีที่แล้ว

      🤣 yeah ... Will work on it asap

  • @gguitarp1
    @gguitarp1 4 ปีที่แล้ว

    Why not just use nodejs’s native crypto module?

    • @TechnoSaviour
      @TechnoSaviour  4 ปีที่แล้ว +1

      You can use, I was focused on showing how it works

  • @ІлляБезуглий-т2з
    @ІлляБезуглий-т2з 4 ปีที่แล้ว

    Thanks for the video, you give a good example, but you are talking way too slow

    • @TechnoSaviour
      @TechnoSaviour  4 ปีที่แล้ว

      Thanks for your suggestion, I'm working on it

    • @kofestar
      @kofestar 4 ปีที่แล้ว

      You can easily set the video speed

  • @adityasahoo7839
    @adityasahoo7839 3 ปีที่แล้ว

    Facing some problem while encrypting with private key and decrypting with public key.
    Here is my code sample
    const nodeRsa = require('node-rsa');
    const key = new nodeRsa({ b: 1024 }),//public and private keys
    publicKey = key.exportKey('public');
    privateKey = key.exportKey('private');
    let encryptedString = keyPrivate.encrypt("Secret", 'base64');
    let decryptedStrig= keyPublic.decrypt(encryptedString, 'utf8');
    Am getting the error message as
    Error during decryption (probably incorrect key). Original error: Error: This is not private key
    This message during decrypt.
    Please help.
    Thanks for this lovely video though.

    • @TechnoSaviour
      @TechnoSaviour  3 ปีที่แล้ว +1

      You are using private key for encryption and public key for decryption.
      It should be other way round

    • @TechnoSaviour
      @TechnoSaviour  3 ปีที่แล้ว

      Let encryptedstring = keyPublic.encrypt(......

  • @SSinghalS
    @SSinghalS 2 ปีที่แล้ว

    I am new to this, I have everything the same, but when I try to run it, the output is not displayed, could you tell me the reason?

  • @dennisgonzales9521
    @dennisgonzales9521 3 ปีที่แล้ว

    Thanks

  • @Cdswjp
    @Cdswjp 2 ปีที่แล้ว

    I find it interesting that u use the public key for encryption & the private key for decryption. I usually read about it being the other way around. What is the reasoning behind doing this in your opinion?

    • @alejandrobermudez8799
      @alejandrobermudez8799 2 ปีที่แล้ว

      Encrypt with public key an decrypt with private key is the way. Please watch the following video: th-cam.com/video/AQDCe585Lnc/w-d-xo.html&ab_channel=SimplyExplained

    • @saditya
      @saditya 2 ปีที่แล้ว

      depends who is sending the data to whom