Tệp thông tin xác thực không là gì ngoài tệp cấu hình với một chút mã hóa và cấu trúc bảo mật ẩn trong phần phụ trợ. Có thể có trường hợp bạn gặp phải các loại tệp này khi sử dụng một số loại nền tảng đám mây. Tất cả những gì bạn làm để đăng nhập vào phiên bản hoặc cấp cho tập lệnh quyền để làm điều gì đó mà không cần tên người dùng và mật khẩu của bạn có vẻ hơi kỳ diệu nhưng nếu bạn muốn làm điều tương tự thì sao? . Người dùng khá khó chịu khi phải nhập thông tin đăng nhập hoặc cấu hình mỗi khi họ muốn chạy mã. Vậy giải pháp là gì? . cho phép người dùng của bạn tạo tệp Thông tin xác thực hoặc tệp Cấu hình mà tập lệnh sau này có thể sử dụng để nhận thông tin chi tiết mà nó yêu cầu. Và đây là cách thực hiện
Thêm trình tạo tệp thông tin xác thực vào tập lệnh
Thực sự, nó đơn giản như sao chép tập lệnh bên dưới và thêm nó vào gói của bạn nhưng bạn cần hiểu một số điều nếu bạn đang muốn nhận tệp cấu hình hoặc thông tin xác thực tùy chỉnh cho tập lệnh của mình. Đầu tiên, đoạn script bên dưới chỉ chấp nhận đầu vào của người dùng và thêm mã hóa vào một số thứ và ghi nó vào một tệp. Nếu bạn muốn thêm dữ liệu khác, chỉ cần thêm biến mới hoặc ghi trực tiếp vào tệp. Thứ hai, Mã hóa ở đây được thực hiện bằng Fernet trong gói mật mã. Vì vậy, chìa khóa được lưu trữ trong một. key và nếu bạn muốn một số bên thứ ba phá vỡ mã hóa, hãy chuyển đổi tệp trình tạo Thông tin xác thực thành. exe hoặc các định dạng khác không thể đọc dễ dàng
Ghi chú. Tất cả các mô-đun được sử dụng đều được tích hợp sẵn với Python, vì vậy không cần cài đặt bên ngoài
tạo tín dụng. py –
Python3
#CreateCred.py
#Creates a credential file.
from cryptography.fernetimport Fernet
import re
import ctypes
import #Creates a credential file.1
import #Creates a credential file.3
import #Creates a credential file.5
#Creates a credential file.6
#Creates a credential file.7 #Creates a credential file.8
#Creates a credential file.6
from0from1 from2from3from4
from5from3from7from8 from9
from5from3____32from8 from9
from5from3cryptography.fernet7from8 from9
from5from3____42from8 import4
from5from3import7from8 import9Fernet0
#Creates a credential file.6
Fernet2
Fernet3
Fernet2
Fernet5
from0Fernet7
from0from1 import0from3from4
from5import4 from3from7
#Creates a credential file.6
from0import9re0
from0from1 import0from3re5
from5re7 re8from8from8 import1
import2import3from8 import5import6import7import8
from5from3____27from8 import3
#Creates a credential file.6
from0Fernet7
from0from1 ctypes9____23from4
from5import4 from3cryptography.fernet7
#Creates a credential file.6
from0#Creates a credential file.08re0
from0from1 ctypes9____23#Creates a credential file.14
from5from3____32from8 #Creates a credential file.19
from5#Creates a credential file.21____28 #Creates a credential file.23from3#Creates a credential file.25
from5from3____37from8 #Creates a credential file.30
from5#Creates a credential file.32 #Creates a credential file.21
#Creates a credential file.6
from0Fernet7
from0from1 #Creates a credential file.39from3from4
from5import4 from3import7
#Creates a credential file.6
from0____148re0
from0from1 #Creates a credential file.39____23#Creates a credential file.54
from5#Creates a credential file.56#Creates a credential file.57from8 #Creates a credential file.59from4
import2from3____47from8 #Creates a credential file.65
#Creates a credential file.6
#Creates a credential file.6
from0from1 #Creates a credential file.70from3from4
from5#Creates a credential file.74
from5#Creates a credential file.76
from5#Creates a credential file.78
from5#Creates a credential file.74
#Creates a credential file.6
from5#Creates a credential file.83from8 #Creates a credential file.85
#Creates a credential file.6
from5#Creates a credential file.88#Creates a credential file.89#Creates a credential file.90#Creates a credential file.91#Creates a credential file.92
import2#Creates a credential file.94#Creates a credential file.95
import2#Creates a credential file.97#Creates a credential file.98import6from3from01from3from03from3from05
import2#Creates a credential file.94from08from09from10import8
#Creates a credential file.6
#Creates a credential file.6
from5from15
from5#Creates a credential file.56from18from3from20
import2from22____23from24
#Creates a credential file.6
from5from27
from5from29
from5from31____232
#Creates a credential file.6
import2from35____28 from37
import2#Creates a credential file.56 from40from8from8 from43from4
from45from3______42from8 from49 from50 from3import2
#Creates a credential file.6
import2#Creates a credential file.88#Creates a credential file.89import6from3from59#Creates a credential file.91from61
from45from63____23from65
from45from67
from45from69
from45#Creates a credential file.56from40from8from8 from75from4
from77from78from3from59#Creates a credential file.59import8
from45from84from32
from77from87
#Creates a credential file.6
from5from90 from91
import2from22____23from24
import2from97____46from99import8
_______42____302
#Creates a credential file.6
from5from3from7from8 from9
from5from3cryptography.fernet7from8 from9
from5from3____32from8 from9
from5from3import2
#Creates a credential file.6
#Creates a credential file.6
from1 cryptography.fernet25
#Creates a credential file.6
from0____328
from0cryptography.fernet30from8 cryptography.fernet32
#Creates a credential file.6
from0cryptography.fernet35
from0______337from8 import5import6cryptography.fernet41import8
from0______344from8 import5____46cryptography.fernet48import8
from0______297____46cryptography.fernet53import8
from0______356from8 cryptography.fernet58import6import5import6______362import8cryptography.fernet64 cryptography.fernet65import8
#Creates a credential file.6
from0cryptography.fernet69
from0____371
from0______297____46cryptography.fernet75from09from10import8
from0____297____46cryptography.fernet82
from0_______197#Creates a credential file.98cryptography.fernet86
#Creates a credential file.6
from0_______156 cryptography.fernet90____576Fernet62import84from8from8 import9Fernet0from4