How to Encrypt and Decrypt Files using Python

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 77

  • @imnoob2675
    @imnoob2675 2 года назад +13

    WOW ! Thanks ! Best tutorial ever ! I modified the script for make a Input for choose the file (path) you want to crypt . Really nice , its work with all documents (even the .png) ! Thanks so much ! 😄😊😉🙂

  • @pdep
    @pdep Год назад +1

    Nicely presented, just how I like it - organized, simple, straight-forward and, most importantly, no fluff, diversions, asides or unnecessary chatter. A really nice job. Thank you.

    • @MishaSv
      @MishaSv  Год назад

      Glad you enjoyed it!

  • @govinej
    @govinej 3 года назад +4

    Great video, it's very insightful and I learned alot...
    I'm going to build a password manager and I needed some form of basic encryption.
    You helped me out today thank you ...

  • @khalidhussain5830
    @khalidhussain5830 9 месяцев назад +2

    After so many hours I found you and thankyou !!!

    • @MishaSv
      @MishaSv  9 месяцев назад +2

      I’m happy the tutorial is helpful!

    • @khalidhussain5830
      @khalidhussain5830 9 месяцев назад +2

      @@MishaSv Bro , I created Encryption and Decryption app by your idea, in this app I provide some functionality like you can encrypt and decrypt text not only just text you can encrypt and decrypt the file and message which appear your files has been saved, After creating that app I got 2nd position in my class on Science Exhibition Day, and I am really gladd thankyou so much , this tutorial really help me

    • @MishaSv
      @MishaSv  9 месяцев назад

      ⁠​⁠@@khalidhussain5830I’m happy it helped you! Subscribe to the channel and check out my other programming tutorials!

  • @pankajKushwaha085
    @pankajKushwaha085 3 месяца назад +1

    Thank you for this fantastic video on encryption and decryption! Your explanations were clear and insightful, making a complex topic easy to understand. I truly admire your ability to break down such intricate concepts so effectively. Keep up the great work!

    • @MishaSv
      @MishaSv  2 месяца назад

      Glad it was helpful!

  • @vapenhem1679
    @vapenhem1679 3 года назад +4

    Best video ive seen, it's sad that all copypaste videos are getting recommended over this. GREAT STUFF!!

    • @MishaSv
      @MishaSv  3 года назад +1

      Thank you!

  • @bhavikpunmiya9641
    @bhavikpunmiya9641 11 месяцев назад +1

    You Really Earned a subscriber bro, I have learned alot and surely gonna apply in projects

    • @MishaSv
      @MishaSv  10 месяцев назад

      Thank you!

  • @AdityaPandey-vu2tf
    @AdityaPandey-vu2tf Год назад +2

    Great sir , really very very impressive teaching way and knowlodge.

  • @laythabdulkareem1887
    @laythabdulkareem1887 Год назад +1

    Code works 100% 👍
    You're super amazing!

  • @kfithen
    @kfithen Год назад +1

    Very helpful. I kept trying to learn this from ChatGPT, but it kept giving me the wrong answers and my code didn't work. Thank you!

    • @JarppaGuru
      @JarppaGuru Год назад

      yes its chatgpt it not know is answer correct or not. you need allways check. i mean correct LOL

    • @MishaSv
      @MishaSv  Год назад

      Glad it helped!

  • @crazex193
    @crazex193 2 года назад +2

    how can i encrypt files that are in a directory

  • @whoyouare7359
    @whoyouare7359 18 дней назад

    hello I want to ask, if I don't have the key, can it still be decrypted? If possible, what should I do?

  • @subhendumondal7784
    @subhendumondal7784 Год назад +1

    Nice tutorial... thank you...
    Can I decrypt any PHP files which is already Encrypted by this technique ?

    • @MishaSv
      @MishaSv  8 месяцев назад

      You can if you have the encryption key.

  • @crispol4053
    @crispol4053 Год назад

    I have similar code to encrypt multiple files, but it is really way too slow if the files are about 50+ files and have videos in it, I dont know what to do to speed it up

  • @YohanceToye
    @YohanceToye 10 месяцев назад +1

    i have an issue "ModuleNotFoundError: No module named 'cryptography'" any chance you know how to solve this

    • @MishaSv
      @MishaSv  8 месяцев назад

      Have you installed the required module?
      If not, then open terminal and run:
      pip install cryptography

  • @romangeneral23
    @romangeneral23 2 года назад +1

    Hello,
    What do we do with the encryption key ? If for example I need to build a Production level app. How do I handle the encryption key ? Its bad practice to store it with the program. It is bad practice to hardcode the key into the code. What is the best approach ?

    • @MishaSv
      @MishaSv  2 года назад

      You can store it in some SFTP folder as a file which is read whenever you do operations with files in a production level app.

  • @joymackey8218
    @joymackey8218 8 месяцев назад

    The only problem with encryption I tried it i encrypted a python script and tried running it it won't run it shows the encryption in cmd and invalid syntax

  • @mohitkumargautam3692
    @mohitkumargautam3692 Год назад +1

    Can I use it for all my python file or it is only for CSV file?

    • @MishaSv
      @MishaSv  Год назад

      You can use it for any file.

  • @usefgadallah738
    @usefgadallah738 2 года назад +1

    The encryption key is not appearing in the mykey.key file. The file is empty.

    • @MishaSv
      @MishaSv  2 года назад

      You should try reinstalling the library and check again. What IDE are you using? I recommend to run it in VS Code, because if you need any additional plugins, it will let you download them right away, and you should see the key inside the .key file.

  • @Fullrusher
    @Fullrusher 2 года назад

    How secure is this method, Im considering learning code again and thing I'd go back to making lil apps and found this subject to be interesting , do you think this would make a safe and secure enough encryption for an application?

  • @quincychung5976
    @quincychung5976 Год назад

    So the .key file type is considered as unlnown so read function doesnt work, anyone can help tell what needs to be done

  • @CRjosh17
    @CRjosh17 2 года назад +1

    hi Misha. Thank you for the tutorial. Is there any way that I can just decrypt the file, and use those values in my code without having to create another file and write the decrypted data?

    • @MishaSv
      @MishaSv  2 года назад

      Yes you can!
      Use the code on lines 23-28 shown at 9:00 - 10:26. When you decrypt the file, it gets stored in a *decrypted* variable, and then you can use it in your code without having to write it out and read in again.

  • @tomfiszelson1485
    @tomfiszelson1485 2 года назад +1

    hi, pretty sure that this account isn't active anymore, but if someone see this message, what's the use of opening the file with "rb" for example and not "r" i understand that b is binary but why do i am supposed to use that ? ( I'm french excuse my horrible english level )

    • @ChrisTheCringe
      @ChrisTheCringe Год назад +1

      The 'b' stands for binary. Useful for reading and writing non-text or non-printable characters when you are doing projects such as this.

  • @sararara3277
    @sararara3277 2 года назад +1

    Hi what kind of encryption type are you using?

    • @MishaSv
      @MishaSv  2 года назад

      Symmetric encryption with Fernet

  • @Runawaygeekchannel
    @Runawaygeekchannel 3 года назад +1

    This was a symmetric key right? Assume using the asymmetric key pair works too?

    • @MishaSv
      @MishaSv  3 года назад +1

      There is a different way you should construct the keys for asymmetric encryption, because now you would need pairs to be created.
      Here is a good example how to do it: nitratine.net/blog/post/asymmetric-encryption-and-decryption-in-python/

  • @avneeshgupta1139
    @avneeshgupta1139 3 года назад +1

    Bhai I have a encrypted .Gem file and I have its encryption key too then please can you tell me the way to undo it again into mp4 video please help🙏🏻

    • @MishaSv
      @MishaSv  3 года назад +1

      This is the closest I could find for your question: github.com/itay-grudev/encryption

    • @avneeshgupta1139
      @avneeshgupta1139 3 года назад

      Thankyou so much for your response🙏🏻
      Actually I am new in this field so that’s why I don’t know much about the source code and how to use this.It will be very great full if you make a program or share the tutorial to use the source code which you shared just now.Actually encrypted videos are my semester lectures that why I need it the most.Please help brother🙏🏻
      And please share the contact so that I will be in touch with you🙏🏻

  • @MPG187
    @MPG187 3 года назад +3

    Can you please use a larger font size? I can't see!!!

    • @MishaSv
      @MishaSv  3 года назад +3

      Thank you for your feedback! I will create larger font in the future videos!
      You can also access the content of the tutorial with step by step instructions on my Python blog:
      pyshark.com/encrypt-and-decrypt-files-using-python/

  • @ycersps9638
    @ycersps9638 2 года назад +1

    hi misha , the video was amazing , but to be honest I'm stuck at VS "cryptography.fernet " isn't working could you help me what I need to add to VS , its my first year as software eng student and that's 1 of my projects in python , could you help me please?

    • @MishaSv
      @MishaSv  2 года назад +1

      Did you install the library from the command line?
      pip install cryptography

    • @ycersps9638
      @ycersps9638 2 года назад

      @@MishaSv i've tried at like 55 times , doesn't work ;/ , idk what to do still clueless

    • @MishaSv
      @MishaSv  2 года назад +2

      This probably has to do with your Python interpreter in VS Code.
      What you want to do is open VS Code and press Ctrl+Shift+P and type "Python interpreter" you should see an option: "Python: Select Interpreter", click on it and you will see many Python interpreters available, try selecting one and see whether the underline will disappear in the code and you can run it. If it doesn't work, try a different Python interpreter.
      Here is the link explaining Python environments in VS Code: code.visualstudio.com/docs/python/environments

    • @ycersps9638
      @ycersps9638 2 года назад

      @@MishaSv I tried everything in the video but still the same problem, tbh I feel really bad and don't know how to do it, do you have discord by any chance you could teach me how to fix this problem?

  • @perrysatoshi8528
    @perrysatoshi8528 2 года назад

    Hello and thank you for your video! I have managed to get my .py script, encrypted.
    But now i'm stuck on the next step, how to make it possible to run the encrypted .py file on raspberry.
    So for example i have script in .py, i want to share this script with other people, to enable them to run my script on their raspberry, but i want to keep the code within the script encrypted.
    Do you have any pointers for me on how to do this?
    Thanks in advance! And again thanks for the great video!

  • @amaanashiqaa
    @amaanashiqaa 2 года назад +1

    does this work with image file?

    • @MishaSv
      @MishaSv  2 года назад +1

      Yes, it should work with any file

  • @benniiiz
    @benniiiz 2 года назад +1

    Can it be used for doc files?

    • @MishaSv
      @MishaSv  2 года назад

      Yes, it can be used on other file formats.

  • @gleemistaken
    @gleemistaken 3 года назад +1

    Thank!
    you

    • @MishaSv
      @MishaSv  3 года назад

      You are welcome!

  • @atishdungdung7871
    @atishdungdung7871 2 года назад +1

    how to encrypt and decrypt arcade

    • @MishaSv
      @MishaSv  2 года назад

      What do you mean by arcade?

    • @atishdungdung7871
      @atishdungdung7871 2 года назад

      @@MishaSv sorry Misha actually it was a spelling mistake can you tell me how to encrypt and decrypt arcade

    • @MishaSv
      @MishaSv  2 года назад

      I still don't really understand what you mean by arcade.

  • @tharunkavishka8434
    @tharunkavishka8434 2 года назад +1

    Can i unlock ehi files

    • @MishaSv
      @MishaSv  2 года назад

      You can decrypt the files

  • @gleemistaken
    @gleemistaken 3 года назад +1

    VERY
    VER
    VE
    V
    V
    VE
    VER
    VERY

  • @znqf
    @znqf Год назад +1

    Can you send me the source?

    • @MishaSv
      @MishaSv  Год назад

      pyshark.com/encrypt-and-decrypt-files-using-python/

  • @govinej
    @govinej 3 года назад +7

    Great video, it's very insightful and I learned alot...
    I'm going to build a password manager and I needed some form of basic encryption.
    You helped me out today thank you ...