Encryption program in Python 🔒

Sdílet
Vložit
  • čas přidán 16. 11. 2022
  • #python #course #tutorial
    import random
    import string
    chars = " " + string.punctuation + string.digits + string.ascii_letters
    chars = list(chars)
    key = chars.copy()
    random.shuffle(key)
    #ENCRYPT
    plain_text = input("Enter a message to encrypt: ")
    cipher_text = ""
    for letter in plain_text:
    index = chars.index(letter)
    cipher_text += key[index]
    print(f"original message : {plain_text}")
    print(f"encrypted message: {cipher_text}")
    #DECRYPT
    cipher_text = input("Enter a message to encrypt: ")
    plain_text = ""
    for letter in cipher_text:
    index = key.index(letter)
    plain_text += chars[index]
    print(f"encrypted message: {cipher_text}")
    print(f"original message : {plain_text}")

Komentáře • 130

  • @BroCodez
    @BroCodez  Před rokem +61

    import random
    import string
    chars = " " + string.punctuation + string.digits + string.ascii_letters
    chars = list(chars)
    key = chars.copy()
    random.shuffle(key)
    #ENCRYPT
    plain_text = input("Enter a message to encrypt: ")
    cipher_text = ""
    for letter in plain_text:
    index = chars.index(letter)
    cipher_text += key[index]
    print(f"original message : {plain_text}")
    print(f"encrypted message: {cipher_text}")
    #DECRYPT
    cipher_text = input("Enter a message to encrypt: ")
    plain_text = ""
    for letter in cipher_text:
    index = key.index(letter)
    plain_text += chars[index]
    print(f"encrypted message: {cipher_text}")
    print(f"original message : {plain_text}")

    • @riufq
      @riufq Před rokem +1

      can you made video about the compaction encryption?

    • @mr.randomly2799
      @mr.randomly2799 Před rokem

      ​@@HS.Anonymous yk wether you like it or not python is going to pretty much be the number one most used language

    • @la_sn3ak3r19
      @la_sn3ak3r19 Před rokem

      it doesnt always work

    • @la_sn3ak3r19
      @la_sn3ak3r19 Před rokem

      When you add string.uppercase it messes with the decryption process occasionally.

    • @eyoel308
      @eyoel308 Před 10 měsíci +1

      what is ur coding app

  • @AM-mv6ro
    @AM-mv6ro Před rokem +213

    I'm 67 and was a complete beginner at programming when I started learning about computing in December 2021. I started with your Python beginner course and I am now a senior Python developer with 3 juniors that I oversee. Thank you Bro Code for your hard work and dedication.

    • @gainzovereverything7719
      @gainzovereverything7719 Před rokem +2

      Teach me 😢

    • @kamal9294
      @kamal9294 Před rokem +2

      Nice

    • @AM-mv6ro
      @AM-mv6ro Před rokem +1

      @@gainzovereverything7719 Sure, how can I assist you?

    • @riufq
      @riufq Před rokem +16

      67?!
      everytime i see people above 50 years old want to learned programming. You guys just make me feel motivated.

    • @gainzovereverything7719
      @gainzovereverything7719 Před rokem +5

      @@AM-mv6ro How did you get your job after learning python?

  • @disdoodanimations
    @disdoodanimations Před rokem +9

    great video, your explaining is really good, i cant wait for your next video!

  • @zabehullahalizadeh2310
    @zabehullahalizadeh2310 Před rokem +5

    Thank you Bro Code . You are really active and you are doing very well. Keep on going

  • @MacN_
    @MacN_ Před rokem +2

    These videos you've created are so helpful. thank you so much!!! NM✌

  • @oumarelfarouqdiarra6619
    @oumarelfarouqdiarra6619 Před rokem +5

    Thanks for all these helpful and very interesting videos ☺️

  • @avivagmon9315
    @avivagmon9315 Před rokem +3

    Bro code on his way to be a complete chill dude that dedicates every video to a fundraiser.
    Pfp checks out

  • @shazamvirk750
    @shazamvirk750 Před rokem

    Amazing information..thanks sir

  • @recon6660
    @recon6660 Před rokem +1

    wow that was awesome knowing how this work.

  • @skeledum
    @skeledum Před 7 měsíci

    Thanks man, you helped me out

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

    Just fantastic 😊

  • @serenity.111
    @serenity.111 Před rokem

    great contents, thank u so much

  • @moneyexploit
    @moneyexploit Před 3 měsíci

    Love You Bro Code
    I Learned Python Paid Courses But They Teach Me About Basic Things In Python. But I Want to Deeper Understand in Python. Then I See Your Video I Learns a Lot's of Things More Than My Paid Courses. Thank you So Much. Love Again

  • @cashflow5075
    @cashflow5075 Před rokem +4

    Thanks for the tutorial bro, can u make some pygame tutorial?

  • @M7ilan
    @M7ilan Před rokem +1

    Do more please with this topic.

  • @rtygbf
    @rtygbf Před rokem

    this helped me soo much

  • @Deformed
    @Deformed Před rokem +7

    Hey brother, can you PLEASE do a video on your IDE setup and configuration? Or is it just default PyCharm as-is? I don't really like VS Code

  • @RODRIGO6803
    @RODRIGO6803 Před 10 měsíci +1

    I am too in college working on a final assignment, I will use this to encrypt user passwords for the project. thanks a lot! like and sub.

  • @trxlly
    @trxlly Před rokem

    Thanks!

  • @Koshak87
    @Koshak87 Před 10 měsíci +3

    07:55 - top 10 anime betrayals.

  • @_Default.
    @_Default. Před rokem +4

    Can you please make a tutorial on how to make a “Key input” code? like when you enter the correct key in the input it sends a console log

    • @MetaaR
      @MetaaR Před 6 měsíci +1

      #Checks if key is equal to input.
      userIn=input()
      key="example123"
      if userIn==key:
      print("Yes")
      #Checks if key is inside the input.
      userIn=input()
      key="example123"
      if key in userIn:
      print("Yes")
      #Checks if key is a permutation of the input.
      userIn=input()
      key="example123"
      cntIn=[0]*256
      cntKey=[0]*256
      check=True
      for i in userIn:
      cntIn[ord(i)]+=1
      for i in key:
      cntIn[ord(i)]+=1
      for i in range(256):
      if cntKey[i]>cntIn[i]:
      check=False
      break
      if check:
      print("Yes")

  • @Dunith_Munasinghe
    @Dunith_Munasinghe Před rokem

    Thank you ❤️

  • @aijazbirsfun547
    @aijazbirsfun547 Před měsícem +1

    Radhe Radhe
    Sanatan Hi Satya Hai
    Jai To All Gods & Godesses
    Jai Baba Farid Ji
    Radhaswami Ji

  • @ardcodelover
    @ardcodelover Před rokem

    Nice

  • @user-fl1cl1sw9m
    @user-fl1cl1sw9m Před 4 měsíci

    thamcuu lavuuuu ummmmmmmmmmmmmmmmmmmmmmmmma..Because of you i've got a place in our uni ❤

  • @user-zq7db7rf6g
    @user-zq7db7rf6g Před 7 měsíci

    broo fire fire,

  • @terrifictable
    @terrifictable Před rokem +2

    can you make a video about rsa/aes encryption (in c or c++)?

  • @rickkk09
    @rickkk09 Před rokem +1

    ma nigga is rocking it

  • @ogfakii9187
    @ogfakii9187 Před rokem +1

    Basically a Caesar Cypher

  • @mr.unknown5307
    @mr.unknown5307 Před rokem +1

    Please make a course on shell scripting

  • @Mosinsarmory
    @Mosinsarmory Před měsícem

    You can make it much shorter by changing it to string.printable which contains all of those characters.

  • @Purple-Astro
    @Purple-Astro Před rokem

    thanks bro

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

    1:32
    x = range(33, 127) # 33-126
    ascii = ""
    for n in x:
    ascii += chr(n)

  • @lukas5238
    @lukas5238 Před rokem +1

    Bro can you show us how to make a preset Timer in Tkinter where if the time is up it prints a text?

  • @abandonedcrack
    @abandonedcrack Před 9 měsíci +1

    I just created the ultimate encrypter, it's not released yet and I'm planning on keeping it closed source to prevent hackers from hacking it.

  • @jameshall4853
    @jameshall4853 Před rokem +2

    How would you expand on this if you could?

  • @danielhod53
    @danielhod53 Před rokem

    bro what keyboard and mic you use?

  • @DarkDeath69420
    @DarkDeath69420 Před 4 měsíci

    one problem with this program is that so it generates random key every time you run it and if i close the program and reopen it i cannot decrypt the text, to solve this you could save key with someone indicator like e-; and then ask user for this indicator and then check if this key exist in the file

  • @OpGamer-kj4ve
    @OpGamer-kj4ve Před rokem +3

    Can you also teach us Ceaser encryption and other types of encryption methods?

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

      #quick and dirty ceasar
      alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      plain_text = "IHATEAPPLE"
      cipher_text = ""
      key = 13 # 1-25 also can use key=alpha.index("N")
      # 13 is btw ROT-13 so you get to flies same time xD
      for letter in plain_text:
      l = len(alpha)
      a = alpha.index(letter)
      k = a + key
      if k >= l:
      k = k - l
      cipher_text += alpha[k]
      print(cipher_text)
      plain_text = ""
      for letter in cipher_text:
      l = len(alpha)
      a = alpha.index(letter)
      k = a - key
      if k < 0:
      k = k + l
      plain_text += alpha[k]
      print(plain_text)

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

      this video is Ceaser Encrytion itself

  • @iloveBTSforever
    @iloveBTSforever Před 4 měsíci

    I have a .wiaw virus from the Stop/Djvu family of viruses. Can this video help?

  • @Force_Drippz
    @Force_Drippz Před měsícem

    if i want the key to not be shuffled so i can share a code to friend like a secret code how do i do it?

  • @nicholasdemakis616
    @nicholasdemakis616 Před rokem

    why cant i see the second enter a message to encrypt im using pycharm is there a setting i need to turn on?

  • @FLKS-3310
    @FLKS-3310 Před 9 měsíci

    how do i make it print the characters that i choose?

  • @VAIBHAVMALHOTRA19
    @VAIBHAVMALHOTRA19 Před 2 měsíci

    Can you please explain for loop part in this code

  • @SashoSuper
    @SashoSuper Před 5 měsíci

    The enemy is not getting the message, but so is your team.

  • @Python902
    @Python902 Před 6 dny

    Well Bro Kindly start the series of Cyber Security yeah AI kindly

  • @djangoKid-uz9oe
    @djangoKid-uz9oe Před 5 měsíci +1

    What IDE are you using?

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

    Pls it doesn’t work when you run the program value error comes indicating that the letter is not in list

  • @user-xk7de1jw8g
    @user-xk7de1jw8g Před 11 měsíci +1

    Your explanation is incredibly excellent Chris. What are you doing these days? I want your help to create an app. Would you do that?

  • @meshoDev
    @meshoDev Před rokem +1

    We can use AES for better encryption
    Good video🫡✨
    Keep it up bro 😎

    • @BroCodez
      @BroCodez  Před rokem +3

      true but that might be too complex for beginners at this level

    • @johnhansen4794
      @johnhansen4794 Před rokem

      @@BroCodez There's a reason I paint my one time pads in Oil.

  • @_______9021
    @_______9021 Před 3 měsíci

    hi i want to know is there any way to encrypt the question or how to find out the key of the cipher code?

  • @SunPodder
    @SunPodder Před rokem +2

    Waiting for your react.js course 🙌

  • @rm_commando5067
    @rm_commando5067 Před rokem +2

    Is there a way to make the user input a key for the code to use?

    • @Someone-nw7yc
      @Someone-nw7yc Před 10 měsíci

      probably ask for user input and let the program return/print the original message if password correct

  • @karolynepessoa8959
    @karolynepessoa8959 Před 7 měsíci

    i need do make a app with symmetric and asymmetric cipher. Do you think that i can use this program??

  • @short-shots
    @short-shots Před rokem +1

    Cant believe we are getting them for free

  • @zarqanawaz7129
    @zarqanawaz7129 Před měsícem

    Which libraries require for it

  • @Der_Rotsteiner
    @Der_Rotsteiner Před rokem +1

    How to use "filetree" in Python

  • @A_Basic_Guy
    @A_Basic_Guy Před rokem

    This didn't work for me, there is nothing wrong with the code but when i reopen the program the encrypted message or numbers to say wil come out as a hole different thing.

  • @codingworld-programmerslif430

    Hello, how about you start cyber security course for beginners...?

  • @mdfaisalmahamud
    @mdfaisalmahamud Před rokem

    javascript project video upload please

  • @massswitch6661
    @massswitch6661 Před 4 měsíci

    Nice video, what is the "f" stand for, and also the " : " next to the words.

    • @talaramadan1895
      @talaramadan1895 Před 3 měsíci

      this is an f string, and the colon is used in the for loops, to end a condition. so its like for index in chars do this (aka:)

  • @wsnippets
    @wsnippets Před rokem

    1st comment

  • @Ahmed_760
    @Ahmed_760 Před 3 měsíci

    how can we encrypt videos?

  • @DADIroRohman
    @DADIroRohman Před 6 měsíci

    w

  • @adedamolayusuf7018
    @adedamolayusuf7018 Před rokem +3

    your voice sounds a bit different in this video. Hope to see your face in a video

    • @BroCodez
      @BroCodez  Před rokem +2

      It might be because I've been sick lately 😷

    • @adedamolayusuf7018
      @adedamolayusuf7018 Před rokem

      @@BroCodez Sorry to hear that bro hope you are feeling better now.

  • @TheFkedOnes
    @TheFkedOnes Před 11 měsíci

    Wich version of python is this?

  • @-hackers_industry
    @-hackers_industry Před rokem

    "How the heck do you spell punctuation!?":
    Bro Code, 2023

  • @wsnippets
    @wsnippets Před rokem

    Love you bro code

  • @pythonmini7054
    @pythonmini7054 Před 11 měsíci

    It only works on txt file not on docx files

  • @JC-fd8ho
    @JC-fd8ho Před rokem

    is that substitation encryption ?

  • @vadimkondratiev7214
    @vadimkondratiev7214 Před 5 měsíci

    a question from a noob. If the encryption is random every time, how can it be used to encrypt and decrypt the messages on a constant basis?

    • @user-ee2fu8gh7e
      @user-ee2fu8gh7e Před 4 měsíci

      please use goole translator to translate Chinese into English.
      因为randomruffle()在整个程序的最外层,先执行random,生成了一个暗号,再执行加密解密。这个暗号在程序本次执行过程中是不变的,但是在每次点击三角,也就是新的一次执行全部程序的时候,暗号会出现变化。你说的情况当randomshuffle()在加密和解密两段代码的内部时会出现。

    • @talaramadan1895
      @talaramadan1895 Před 3 měsíci

      if you still have the program running without ending and starting again, it would have the same key. but here when he re starts the program it generates a new key. so a way to overcome this is by saving the key in a variable after its been randomly generated for the first time. hope this helps!

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

    How 2 people to using it? 😊😊😊

  • @pawan4920
    @pawan4920 Před rokem

    B

  • @al-cadaalachannel3194

    Did you begin advanced level bro?

  • @obaidali8813
    @obaidali8813 Před rokem

    Please we need Javascript

  • @julieannmagsino1733
    @julieannmagsino1733 Před rokem

    what use application in pc and i download for to create this code

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

    what text editor is that

  • @seanchristiangarais3189
    @seanchristiangarais3189 Před rokem +1

    Can I do this on C#?

    • @TotallyNotAPie
      @TotallyNotAPie Před 4 měsíci

      Well you basically just translate the python code to c# code. Although its not gonna be exactly the same

  • @paxi5765
    @paxi5765 Před rokem

    can you decrypt when key lost

  • @aweawertable
    @aweawertable Před rokem

    Do i need to be good in math to be a programmer?

    • @TotallyNotAPie
      @TotallyNotAPie Před 4 měsíci

      Not for everything but you do need some basic math like algebra

  • @mehdi_craft
    @mehdi_craft Před 6 měsíci

    I think its a little hard

  • @deletoblue6059
    @deletoblue6059 Před rokem

    no way

  • @arshiaa104
    @arshiaa104 Před rokem +1

    Cumment

  • @zstar8397
    @zstar8397 Před 7 měsíci +1

    Hey hope you are doing alright just I wanna say that
    GOD loved the world so much he sent his only begotten
    son Jesus to die a brutal death for us so that we can have eternal life and we can all accept this amazing gift this by simply trusting in Jesus, confessing that GOD raised him from the dead, turning away from your sins and forming a relationship with GOD.

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

    1:54
    x = range(32, 127) # 32-126
    ascii = ""
    for n in x:
    ascii += chr(n)