How do I encrypt/decrypt a dictionary in Python 3.3? [duplicate] - python

This question already has answers here:
How do I encode/decode a dictionary in Python 3 to/from an external file?
(3 answers)
Closed 9 years ago.
I have a dictionary, myDict = {1:'a',2:'b',3:'c'}, that I'd like to encrypt and write to an external raw text file.
I've already downloaded and installed PyCrypto since a lot of other threads seem to recommend it, but it's too confusing for me to grasp its terminology and syntax.
Could someone explain how I'd go about doing this in Layman's terms?

Encode the dict as a string with e.g. json, and then encrypt the resultant string.

Related

Where is the python core file located [duplicate]

This question already has answers here:
Finding the source code for built-in Python functions?
(8 answers)
Closed 1 year ago.
As we know in Python 3.0 turned print in the function form so I want to know where is the file with source of print function is located
You seems to ask about builtin function.
The python interpreter has predefined functions that are always ready for use.
https://hg.python.org/cpython/file/tip/Python/bltinmodule.c

What is [...] in Python Language [duplicate]

This question already has answers here:
What does "three dots" in Python mean when indexing what looks like a number?
(3 answers)
What does the Ellipsis object do?
(14 answers)
Closed 2 years ago.
So I have created a suffix tree using python and when I was printing my suffix tree, I came across one list that contains [...] at one of its indexes. I searched online and couldn't find anything regarding it. It would be really great if someone could explain to me that what does [...] mean in python. By the way, I'm using PyCharm IDE, not sure if it's an IDE specific issue. Cheers!

How to make a .py file not human readable? [duplicate]

This question already has answers here:
How to obfuscate Python code effectively? [duplicate]
(22 answers)
Closed 3 years ago.
I have a script in .py format and random forest in pickle format and i should deliver it to a customer . He should not be able to read both.
If you really have to hide the code **, I recommend you to use an obfuscator
An example: https://wiki.python.org/moin/Pyarmor
PS: you have a similar question here: How to obfuscate Python code effectively?
Also, this is something I never did or explored, but through PYC-only distribution could be an alternative, but you must explore this by yourself.
Find out more at https://www.curiousefficiency.org/posts/2011/04/benefits-and-limitations-of-pyc-only.html
*** I know obfuscating code is not nice, but sometimes companies require it :/

How do I store data that it is inputted forever? [duplicate]

This question already has answers here:
How to save a dictionary to a file?
(12 answers)
Closed 5 years ago.
I want to take an input from someone and save it in a dictionary even after I end the program so that I can run it again and retrieve the information. How do I do this?
You need to save the information to a file or database when the program ends and reload it when it starts. Pickle is one way you can do that.

Generating tokens in Python [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Is there a good Python library that can parse C++?
I want Python to scan through a file (a .cpp file) and generate tokens from it using the in-built Python tokeniser.How can this be achieved?
The built-in tokenizer and ast stuff is for parsing Python, not other languages like C++.
You may want to look at GCC-XML.

Categories

Resources