07.07.2023 Views

Implementing-cryptography-using-python

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 1 ■ Introduction to Cryptography and Python 3

this book will work. If you are on a Mac, you can use the Terminal app found

inside the Utilities folder. On a Windows machine, you have several options

as well: you can install a number of tools such as Cygwin, Visual Studio, or

PyCharm; use the Windows 10 Linux subsystem; or just install Ubuntu Linux

from the Microsoft Store. If you are new to Linux, I recommend practicing your

command-line skills a bit to help get you comfortable.

When you start the Python shell (by typing python or python3 at the command

line), you will see the version and the date associated with the version. For instance,

if you install and run Python in a Linux environment, you should see

something similar to the following:

Python 3.7.4+ (default, Sep 4 2019, 08:03:05)

[GCC 9.2.1 20190827] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>>

The majority of Python interpreters use >>> as a prompt to accept user input;

one notable exception is IPython, which is discussed briefly in a moment. Once

you are in a Python shell, exit by pressing CTRL+D or typing exit(). Python

files use a .py extension, and we start their execution in Linux environments

by typing python3 filename.py; (keep in mind that you still need to chmod

+x the file).

NOTE In Unix-like operating systems, the chmod command sets the permissions

of files or directories.

As you will learn later in this chapter, a large number of modules are available

for Python, many of which we will use along your journey of learning

cryptography. One of the more notable modules you will learn more about is

NumPy. NumPy offers numerical operations to Python, including fast multidimensional

array operations, random number generation, and linear algebra.

Another module that you will be introduced to is Matplotlib, which is an excellent

library for plotting. In Chapter 6, you will learn more about PyFITS, which

is a module that provides access to Flexible Image Transport System (FITS) files.

FITS is a portable file standard that is widely used throughout the astronomy

community to store images and tables. We will be combining it with our cryptography

techniques to encrypt and decrypt image files.

Downloading and Installing Python

You can download the Python interpreter from www.python.org/python, where

you’ll find versions for Ubuntu, macOS, and Windows. Be sure to download

version 3.7 or higher, since Python 2 is now unsupported.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!