Json module using module hashlib

"" " 
# Json & pickle module
# 1. What is the sequence of
# 2. Why have the sequence of
# 3. How do serialization and de-serialization
1. serialization refers to the conversion of memory data into a specific type of content format , the contents of the format
may be used for storage or transmission to other platforms using the
data types of memory ------ "serialization -----------" specific format (json, pickle mode)
memory data type "------- deserialization" --------- specific formats (json, pickle mode)
2. how have serialization?
serialization get results ---- "specific format use two purposes
1 can be used to store ---- "is used to archive
2. transferred to other platforms -----" cross-platform data exchange
emphasized: the format for a particular purpose 2: It should be a universal, All languages can be recognized json format
for a particular purpose format 1: should be a special mode the pickle


"" "
Import json
RES = json.dumps ([1, 'AAA', True, False])
Print (RES, type (RES)) # [. 1, "AAA", to true, to false] <class 'STR'>
RES = json.loads (RES)
Print (RES, type (RES)) # [. 1, 'AAA', True, false] <class 'list'>

# Serialized result file easy way to write
Open with ( "test.json", "wt", encoding = "UTF-. 8") AS F:
The json.dump ([666, 'Yoona', False, True], F)
with Open ( "test.json" , "RT", encoding = "UTF-. 8") AS F:
RES = the json.load (F)
Print (RES)
#JSON verification: json format is compatible with common data type for all languages, the language can not identify a single type
# json.jumps ({1,2,3,6,4})
#JSON stressed: clear json format, not to be confused with the python
"" " 
What is a hash hash?
Hash is an algorithm that receives incoming content, after a string of hash value calculation to obtain
the characteristics of hash values:
the same 1.1 incoming content, the resulting hash value as inevitable
1.2 can not be decomposed into the hash value of the inverse contents of
1.3 as long as the same hash algorithm, hash values obtained length is constant
use of 2.hash
12345abc ------> hash string
client ------ ---------- server -hash string
hash value encrypted password that is
characteristic for 1.2 cipher text transmission and authentication
features 1.1 and 1.3 for the file integrity check
3. how?

"" "
# --------- hash plant material --------- hash value
" ""
Import hashlib
m = hashlib.md5 ()
m.update ( "Hello" .encode ( "UTF- 8 "))
m.update (b" world ")
RES = m.hexdigest ()
Print (RES)
# hit the library to crack the code using the
Import hashlib
# RES = hashlib.md5 (b" yoona123 ")
# RES = RES.hexdigest ()
# print (anything)
name = {}
= pwd "a26bdd1136c3401ed70d8e45a6c52751"
Passwords = [ "yoo12na3", "yo12ona3", "321noyao", "yoona123", "yoo321na"]
for I in Passwords:
RES = hashlib.md5 (i.encode ( "UTF-. 8"))
DIC [I] = res.hexdigest ()
Print (DIC)
for K, V in dic.items ():
IF V == pwd:
Print ( "password cracking success password S%!"% K)
BREAK

"" "
# ---- lifting costs hit library "password salt
Import hashlib
m = hashlib.md5 ()
m.update (" Moon Water cage yarn Yanlong cold ".encode (" UTF-. 8 "))
m.update (" Hello ".encode (" UTF-. 8 "))
m.update (" Bells Qinhuai near Restaurant ".encode (" UTF-. 8 "))
Print (m.hexdigest ())

Guess you like

Origin www.cnblogs.com/mayrain/p/12607042.html