当前位置:网站首页>UUID and secrets module
UUID and secrets module
2022-07-27 07:27:00 【X?】
List of articles
1.uuid What is it? ?
UUID yes Universally Unique IDentifier( Universally unique identification )
UUID Represents the universal unique identifier , It's a 128 The value of a , Unique identification for software development
UUID The generation of is based on the current timestamp and the generation UUID Unique attribute of workstation
2.UUID The classification of
uuid1
uuid.uuid1([node[,clock_seq]]): Based on timestamps """ Use the host ID, Serial number and current time to generate UUID, It guarantees global uniqueness , But because this method generates UUID Contains the network address of the host , May endanger privacy If node Parameter default , The system automatically calls getnode() Function to get the hardware address of the host If clock_seq default , Then randomly 14 Bit serial number instead """uuid4
uuid.uuid4(): Based on random numbers ''' Generate by random numbers uuid, But the pseudo-random number used has a certain repetition probability '''uuid3
uuid.uuid3(namespace,name): Based on name MD5 Hash value ''' By calculating the name of the namespace and MD5 Hash values to generate uuid, It can guarantee the uniqueness of different names in the same namespace and the uniqueness of different namespace ''' uuid.uuid3(uuid.NAMESPACE_DNS,'456')uuid5
uuid.uuid3(namespace,name): Based on name SHA-1 Hash value ''' By calculating the name of the namespace and SHA-1 Hash value generation uuid, Algorithm and uuid3 identical ''' uuid.uuid5(uuid.NAMESPACE_DNS,'456')
3. What is? Secrets
secrets yes python3.6 Added to the standard library , Use secrets modular , Can be generated for processing confidential information ( Such as password , Account authentication , Security Token ) Of
encryptionStrong random number .
| Common functions | explain | example |
|---|---|---|
| choice(sequence) | Select an element from a non empty sequence | secrets.choice([23,3,5,6]) |
| randbelow(n) | Random one [0,n) The integer of | secrets.randbelow(10) |
| randbits(n) | stay n Bit length random one bit in the range of binary numbers | secrets.randbits(10) |
| token_bytes(n) | Random generation n Within bytes bytes Type string | secrets.token_bytes(2) |
| token_hex(n) | return n Bit length 16 Hexadecimal random text string | secrets.token_hex(2) |
| taken_urlsafa(n) | The returned bytes are nbytes Of URL Secure text string . The text is written with Base64 code , Each byte averages about 1.3 Characters . | secrets.token_urlsafe() |
| compare_digest(str,str) | String comparison , Equal return True | secrets.compare_digest(‘a’,‘a’) |
边栏推荐
- The difference between critical section (the code that accesses critical resources in each thread) and mutex (mutex between processes, shared memory, virtual address)
- C# 常用功能整合-3
- A small cotton padded jacket with air leakage
- 35. Search insert position
- Linear table -- stack and queue
- Pg_relation_size 问题
- 查看服务器重启前的 dmesg 日志
- Internal class -- just read this article~
- 2022-07-25 顾宇佳 学习笔记
- Use reflection to dynamically modify annotation attributes of @excel
猜你喜欢

The possibility of metauniverse from the perspective of technical principles: how Omniverse "built" Mars

Flutter实战-请求封装(一)

Synchronized锁

(2022 Niuke multi school III) j-journey (Dijkstra)

docker安装MySQL8.0.28

Internal class -- just read this article~

JS make a traffic light

Usage of string class

Firefox browser, when accessing Tencent cloud server, failed to establish a secure connection.

海康h9摄像头用xshell无法连接(没有启用ssh)
随机推荐
杂谈:最近好多朋友谈出国……
Which C4d cloud rendering platform to cooperate with?
使用pip命令切换不同的镜像源
Perl: 将要执行的外部命令拆分为多行
C4D云渲染平台选哪家合作?
Sort increment with typescript
The possibility of metauniverse from the perspective of technical principles: how Omniverse "built" Mars
Will Flink CDC constantly occupy Oracle's memory by extracting Oracle's data, and finally cause oracle-040
(2022 Niuke multi school III) a-ancestor (LCA)
Pan Aimin, chairman of instruction set, attended the 2022 ecug con to speak for China's technical forces
多线程【初阶-上篇】
Flutter实战-请求封装(一)
Simple rotation chart
使用sqlplus显示中文为乱码的解决办法
VLAN trunk实验
35. Search insert position
QT连接sqlite数据库的错误及其修改办法
Quickly update the information in a field in kettle
Analysis of query results using both left join on and where in MySQL
Codeforces Round #804 (Div. 2)(5/5)