您好,登錄后才能下訂單哦!
CREATE TABLE society.18wangcode_sha1_hash(id INT(9) AUTO_INCREMENT PRIMARY KEY,
pwd
VARCHAR(60) NOT NULL,hash_values
VARCHAR(40) NOT NULL);
通過hashlib庫將密碼hash后存入數據庫
import mysqlx.connection import time import hashlib import mysql.connector print('begin'.center(30, '*')) print('進行中,請稍等。。。。。。。。') start = time.time() conn = mysql.connector.connect(host='192.168.137.239', user='admin', password='123456', database='society') cursor = conn.cursor() def hash(pwd): method = hashlib.sha1() method.update(pwd.encode('utf-8', errors='ignore')) return method.hexdigest() try: with open(r'C:\Users\11826\Desktop\18萬條密碼.txt', 'r', encoding='utf-8', errors='ignore') as file: for password in file: cursor.execute('insert into society.18wangcode_sha1_hash (pwd, hash_values) values (%s, %s)', (password, hash(password))) except: print('error') finally: cursor.close() conn.commit() conn.close() end = time.time() print('結束,共耗時:{:.2f}秒'.format(end-start))
GitHub地址
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。