I am using vernemq to authorize users from database using SHA256 algorithm. I observe that when creating new entry in table using buildin mqsql function SHA2
,
INSERT INTO vmq_auth_acl
(mountpoint, client_id, username,
password, publish_acl, subscribe_acl)
SELECT
'', 'newUser2', 'newUser2', SHA2("CJJPL9", 256),
'[{"pattern":"botOut"}] ',
'[{"pattern":"botIn/#"}]';
which generates hash value something like this 54d0e30d0a00d86451a3353a2123fc1f006faaba6b55ef0d168390f26cbab82a
and Vernemq server successfully verifies this user when logged in using CJJPL9
password.
But when I add this entry into this table from python code using passlib library sha256_crypt.encrypt("CJJPL9")
, which generates hash as follows
$5$rounds=80000$wnsT7Yr92oJoP28r$cKhJImk5mfuSKV9b3mumNzlbstFUplKtQXXMo4G6Ep5
. I know, due to salt, the hashs will be different, but there is a clear difference in the formatting of both hashes and as a result, verneMQ server fails to verify the credentials for this user. The formatting of passlib library says that it keeps only 43 characters from 256-bit checksum. I also tried testing by only keeping the checksum part of the passlib hash string, but still no luck.
I want to know what is the difference between encryption of MySQL SAH2("CJJPL9", 256)
and sha256_crypt.encrypt("CJJPL9")
.