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 in Python by Ahmed
• 310 points

recategorized Aug 20 by Omkar 117 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 by Simran

selected Aug 20 by Ahmed

Related Questions In Python

0 votes
1 answer
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,720 points
2,175 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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 332 views
0 votes
0 answers
+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
• 56,900 points
154 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 ariaholic
• 7,340 points
171 views