How to Encrypt and Decrypt Files using Python

Поділитися
Вставка
  • Опубліковано 6 лис 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 ! 😄😊😉🙂

    • @asaintbaba1471
      @asaintbaba1471 Рік тому +3

      Can we take a look at it??

    • @haridasmakhar4210
      @haridasmakhar4210 11 місяців тому

      Hi, if you find some time, can you share a script with me

  • @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!

  • @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!

  • @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 ...

  • @vapenhem1679
    @vapenhem1679 3 роки тому +4

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

  • @bhavikpunmiya9641
    @bhavikpunmiya9641 10 місяців тому +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!

  • @crazex193
    @crazex193 2 роки тому +2

    how can i encrypt files that are in a directory

  • @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.

  • @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!

  • @whoyouare7359
    @whoyouare7359 9 днів тому

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

  • @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

  • @sararara3277
    @sararara3277 2 роки тому +1

    Hi what kind of encryption type are you using?

    • @MishaSv
      @MishaSv  2 роки тому

      Symmetric encryption with Fernet

  • @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.

  • @benniiiz
    @benniiiz 2 роки тому +1

    Can it be used for doc files?

    • @MishaSv
      @MishaSv  2 роки тому

      Yes, it can be used on other file formats.

  • @amaanashiqaa
    @amaanashiqaa 2 роки тому +1

    does this work with image file?

    • @MishaSv
      @MishaSv  2 роки тому +1

      Yes, it should work with any file

  • @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

  • @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.

  • @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?

  • @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.

  • @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/

  • @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

  • @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?

  • @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.

  • @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  2 роки тому +1

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

    • @avneeshgupta1139
      @avneeshgupta1139 2 роки тому

      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🙏🏻

  • @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

  • @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!

  • @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/

  • @tharunkavishka8434
    @tharunkavishka8434 2 роки тому +1

    Can i unlock ehi files

    • @MishaSv
      @MishaSv  2 роки тому

      You can decrypt the files

  • @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.

  • @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 ...