Neo4j校验密码生成代码(Python)
在Neo4j的数据目录下有一个dbms目录,里面存储的是身份校验文件auth:
[root@datanode data]# ll total 0 drwxr-xr-x 3 112 nfsnobody 21 Jan 29 14:34 databases drwxr-xr-x 2 root root 17 Jan 29 14:36 dbms [root@datanode dbms]# ls auth
查看auth文件:
[root@datanode dbms]# cat auth neo4j:SHA-256,0A9FC5A9A9C368A3FD2E41F9BB024AAA3CA8808B3428A4EE2D72B13703A7AD5E,FADA2AD5718A00B0DAB07735FFD16038:
文件的内容比较简单,形式是“用户名:加密算法,<根据原始密码生成的密码>,<加密的salt盐>”。如果忘记密码或者想修改密码时,可以手工配置或替换此文件。Python代码如下:
Python 3.x:
import hashlib import codecs username = input("please input your username: ") passwd = input("please input your password: ") salt = input("please input salt: ") salt_byte = bytes(salt.encode()) passwd_byte = codecs.encode(passwd.encode(), 'hex') salt_pass = bytearray.fromhex((salt_byte + passwd_byte).decode()) print(username + ":" + "SHA-256," + hashlib.sha256(salt_pass).hexdigest().upper() + "," + salt.upper() + ":")
Python 2.x:
from __future__ import print_function import hashlib import codecs username = raw_input("please input your username: ") passwd = raw_input("please input your password: ") salt = raw_input("please input salt: ") salt_byte = bytes(salt.encode()) passwd_byte = codecs.encode(passwd.encode(), 'hex') salt_pass = bytearray.fromhex((salt_byte + passwd_byte).decode()) print(username + ":" + "SHA-256," + hashlib.sha256(salt_pass).hexdigest().upper() + "," + salt.upper() + ":")
参考链接:
相关推荐
huha 2020-10-16
TLROJE 2020-10-26
echoes 2020-08-20
nercon 2020-08-01
zhanghaibing00 2020-06-28
Aveiox 2020-06-25
henryzhihua 2020-06-21
zhoutaifeng 2020-06-17
liangzhouqu 2020-06-16
TONIYH 2020-06-11
开心就好 2020-06-10
x青年欢乐多 2020-06-06
KyrieHe 2020-06-03
bertzhang 2020-06-02
haokele 2020-05-29
niehanmin 2020-05-28
davidliu00 2020-05-26