How can i import json file and encrypt it by using ASE MODE CBC encryption ?

0 votes
How can I import json file and encrypt it by using ASE MODE CBC encryption by python (I'm using Ubuntu win)
Aug 20, 2019 in Python by Ahmed
• 310 points

recategorized Aug 20, 2019 by Omkar 1,764 views

1 answer to this question.

+1 vote
Best answer

Hi @Ahmed. Here's a sample code that reads the data from a json file, converts it into a string and then encrypt:

import json
from Cryptodome.Cipher import AES


with open('path_to_file/filename.json') as f:
    text=json.dumps(f)
key = '0123456789abcdef'
IV='0123456789abcdef'
mode = AES.MODE_CBC
encryptor = AES.new(key.encode('utf8'), mode,IV=IV.encode('utf8'))
ciphertext = encryptor.encrypt(text)


answered Aug 20, 2019 by Simran

selected Aug 20, 2019 by Ahmed

Related Questions In Python

0 votes
1 answer

how can i extact all the links from a website using python and save it in a csv file ?

Hi, @Shubham, Web scraping is the technique to ...READ MORE

answered Jun 16 in Python by Gitika
• 36,530 points
178 views
0 votes
1 answer
0 votes
1 answer

How can I upgrade specific packages using pip and a requirements file?

Hello @kartik, According to pip documentation example 3: pip install --upgrade ...READ MORE

answered Aug 5 in Python by Niroj
• 56,680 points
57 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,337 views
0 votes
0 answers
0 votes
0 answers

I do not have a real result about encryption file use AES mode CFB in pycrptodome on python

I'm using Ubuntu win. on python I ...READ MORE

Aug 22, 2019 in Cyber Security & Ethical Hacking by Ahmed
• 310 points

closed Aug 22, 2019 by Ahmed 149 views
+1 vote
1 answer

How can I map input to output without using dynamic()

Here am talking about my example you ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 57,640 points
276 views
0 votes
1 answer

How can I expose callbacks to Fortran using Python

The code that I've written below. The ...READ MORE

answered Aug 23, 2018 in Python by aryya
• 7,380 points
409 views