Cryptography With Python 简明教程
Python Overview and Installation
Python 是一种开源脚本语言,它高级、直譯、互动且面向对象的。它被设计为高度可读。Python 语言的语法易于理解且经常使用英语关键字。
Python is an open source scripting language which is high-level, interpreted, interactive and object-oriented. It is designed to be highly readable. The syntax of Python language is easy to understand and uses English keywords frequently.
Features of Python Language
Python 提供以下主要功能 −
Python provides the following major features −
Key Points of Python Language
Python 编程语言的关键点如下 −
The key points of Python programming language are as follows −
-
It includes functional and structured programming and methods as well as object oriented programming methods.
-
It can be used as a scripting language or as a programming language.
-
It includes automatic garbage collection.
-
It includes high-level dynamic data types and supports various dynamic type checking.
-
Python includes a feature of integration with C, C++ and languages like Java.
Python 语言的下载链接如下 − www.python.org/downloads 它包括 Windows、MacOS 和 Linux 发行版等各种操作系统的软件包。
The download link for Python language is as follows − www.python.org/downloadsIt includes packages for various operating systems like Windows, MacOS and Linux distributions.

Python Strings
字符串的基本声明如下所示 −
The basic declaration of strings is shown below −
str = 'Hello World!'
Python Lists
Python 列表可以声明为复合数据类型,用逗号分隔并用方括号 ([]) 括起来。
The lists of python can be declared as compound data types, separated by commas and enclosed within square brackets ([]).
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']
Python Tuples
元组是 Python 的动态数据类型,由用逗号分隔的多个值组成。元组用括号括起来。
A tuple is dynamic data type of Python which consists of number of values separated by commas. Tuples are enclosed with parentheses.
tinytuple = (123, 'john')
Python Dictionary
Python 字典是一种哈希表。字典键几乎可以是 Python 的任何数据类型,通常是数字或字符串。
Python dictionary is a type of hash table. A dictionary key can be almost any data type of Python, which are usually numbers or strings.
tinydict = {'name': 'omkar','code':6734, 'dept': 'sales'}
Cryptography Packages
Python 包含一个名为 cryptography 的软件包,该软件包提供加密算法和基础函数。它支持 Python 2.7、Python 3.4+和 PyPy 5.3+。通过以下命令完成 cryptography 软件包的基本安装 −
Python includes a package called cryptography which provides cryptographic recipes and primitives. It supports Python 2.7, Python 3.4+, and PyPy 5.3+. The basic installation of cryptography package is achieved through following command −
pip install cryptography
提供了许多带有高级秘方和低级接口的软件包,可用于 symmetric ciphers 、 message digests 和 key derivation functions. 等通用加密算法。
There are various packages with both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests and key derivation functions.
在整个教程中,我们将使用 Python 的各种软件包来实现加密算法。
Throughout this tutorial, we will be using various packages of Python for implementation of cryptographic algorithms.