AES encryption in python | Lec-25

  Рет қаралды 1,054

MANISH KUMAR

MANISH KUMAR

Күн бұрын

In this video, I have talked about the fundamentals of programming and Python. If you complete this, you will be well-versed in using tuples for different use cases.
Directly connect with me at:- topmate.io/man...
Source Code:-
#Requirements:- pip install pycryptodome
pip install pycryptodomex
import base64
from Cryptodome.Cipher import AES
from Cryptodome.Protocol.KDF import PBKDF2
import os, sys
from loguru import logger
try:
key = "key1"
iv = "my_username_pass"
salt = "salt"
if not (key and iv and salt):
raise Exception(F"Error while fetching details for key/iv/salt")
except Exception as e:
logger.error("Error occurred. Details: %s", e)
sys.exit(0)
BS = 16
pad = lambda s: bytes(s + (BS - len(s) % BS) * chr(BS - len(s) % BS), 'utf-8')
unpad = lambda s: s[0:-ord(s[-1:])]
def get_private_key():
Salt = salt.encode('utf-8')
kdf = PBKDF2(key, Salt, 64, 1000)
key32 = kdf[:32]
return key32
def encrypt(raw):
raw = pad(raw)
cipher = AES.new(get_private_key(), AES.MODE_CBC, iv.encode('utf-8'))
return base64.b64encode(cipher.encrypt(raw))
def decrypt(enc):
cipher = AES.new(get_private_key(), AES.MODE_CBC, iv.encode('utf-8'))
return unpad(cipher.decrypt(base64.b64decode(enc))).decode('utf8')
print(encrypt("manish"))
print(decrypt("U1AMRIQSTYosVJCmmqUHnA=="))
Discord channel:- / discord
For more queries reach out to me on my below social media handle.
Follow me on LinkedIn:- / manish-kumar-373b86176
Follow Me On Instagram:- / competitive_gyan1
Follow me on Facebook:- / manish12340
My Second Channel -- / @competitivegyan1
Interview series Playlist:- • Interview Questions an...
My Gear:-
Rode Mic:-- amzn.to/3RekC7a
Boya M1 Mic-- amzn.to/3uW0nnn
Wireless Mic:-- amzn.to/3TqLRhE
Tripod1 -- amzn.to/4avjyF4
Tripod2:-- amzn.to/46Y3QPu
camera1:-- amzn.to/3GIQlsE
camera2:-- amzn.to/46X190P
Pentab (Medium size):-- amzn.to/3RgMszQ (Recommended)
Pentab (Small size):-- amzn.to/3RpmIS0
Mobile:-- amzn.to/47Y8oa4 ( Aapko ye bilkul nahi lena hai)
Laptop -- amzn.to/3Ns5Okj
Mouse+keyboard combo -- amzn.to/3Ro6GYl
21-inch Monitor-- amzn.to/3TvCE7E
27-inch Monitor-- amzn.to/47QzXlA
iPad Pencil:-- amzn.to/4aiJxiG
iPad 9th Generation:-- amzn.to/470I11X
Boom Arm/Swing Arm:-- amzn.to/48eH2we
My PC Components:-
intel i7 Processor:-- amzn.to/47Svdfe
G.Skill RAM:-- amzn.to/47VFffI
Samsung SSD:-- amzn.to/3uVSE8W
WD Blue HDD:-- amzn.to/47Y91QY
RTX 3060Ti Graphic card:- amzn.to/3tdLDjn
Gigabyte Motherboard:-- amzn.to/3RFUTGl
O11 Dynamic Cabinet:-- amzn.to/4avkgSK
Liquid cooler:-- amzn.to/472S8mS
Antec Prizm FAN:-- amzn.to/48ey4Pj

Пікірлер: 17
mysql installation on windows 11 | Lec-26
8:12
MANISH KUMAR
Рет қаралды 602
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 304 М.
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 16 МЛН
А ВЫ ЛЮБИТЕ ШКОЛУ?? #shorts
00:20
Паша Осадчий
Рет қаралды 2,2 МЛН
how to make database connection in python | Lec-27
31:42
MANISH KUMAR
Рет қаралды 893
string in python | Lec-17
34:47
MANISH KUMAR
Рет қаралды 1,2 М.
Enter The Arena: Simplifying Memory Management (2023)
1:47:50
Ryan Fleury
Рет қаралды 38 М.
How to Do 90% of What Plugins Do (With Just Vim)
1:14:03
thoughtbot
Рет қаралды 894 М.
Professional Data Encryption in Python
11:12
NeuralNine
Рет қаралды 57 М.
Apache Kafka Crash Course
1:18:06
Hussein Nasser
Рет қаралды 426 М.
Public Key Cryptography - Computerphile
6:20
Computerphile
Рет қаралды 892 М.