Ich will mich mit AutoHotkey bei meiner Fritzbox (Router) anmelden.
Zum anmelden muss man per POST eine "response" abschicken, die sich aus dem Password und einem md5 hash zusammensetzt.
Den Hash wollte ich mit jNizMs bcrypt_md5(string) erzeugen.
Ich kann den Hash jedoch nicht nachvollziehen.
Die js Funktion auf der Fritzbox erzeugt mit den nachfolgenden Einstellungen den Hash:
Code: Select all
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
/* var chrsz = 8; */ /* bits per input character. 8 - ASCII; 16 - Unicode */
var chrsz = 16; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
..
jNizMs bcrypt_md5(string) erzeugt die Variante mit var chrsz = 8 (Ascii)
ich brauche das Ergebniss das man in der md5.js mit chrsz = 16 (unicode) erhält.
Das hier wird durch die md5.js erzeugt:
var chrsz = 16
hex_md5("The quick brown fox jumps over the lazy dog")=>b0986ae6ee1eefee8a4a399090126837
var chrsz = 8
hex_md5("The quick brown fox jumps over the lazy dog")=>9e107d9d372bb6826bd81d3542a419d6
jNizM:
bcrypt_md5("The quick brown fox jumps over the lazy dog")=>9e107d9d372bb6826bd81d3542a419d6
Gibt es eine Einstellung die ich in bcrypt_md5(string) anpassen kann, oder eine andere md5 funktion?
Code: Select all
MsgBox % bcrypt_md5("The quick brown fox jumps over the lazy dog")
; ==> 9e107d9d372bb6826bd81d3542a419d6
; ==> gewünscht : b0986ae6ee1eefee8a4a399090126837
bcrypt_md5(string)
{
static BCRYPT_MD5_ALGORITHM := "MD5"
static BCRYPT_HASH_LENGTH := "HashDigestLength"
if !(hBCRYPT := DllCall("LoadLibrary", "str", "bcrypt.dll", "ptr"))
throw Exception("Failed to load bcrypt.dll", -1)
if (NT_STATUS := DllCall("bcrypt\BCryptOpenAlgorithmProvider", "ptr*", hAlgo, "ptr", &BCRYPT_MD5_ALGORITHM, "ptr", 0, "uint", 0) != 0)
throw Exception("BCryptOpenAlgorithmProvider: " NT_STATUS, -1)
if (NT_STATUS := DllCall("bcrypt\BCryptGetProperty", "ptr", hAlgo, "ptr", &BCRYPT_HASH_LENGTH, "uint*", cbHash, "uint", 4, "uint*", cbResult, "uint", 0) != 0)
throw Exception("BCryptGetProperty: " NT_STATUS, -1)
VarSetCapacity(pbInput, StrPut(string, "UTF-8"), 0) && cbInput := StrPut(string, &pbInput, "UTF-8") - 1, VarSetCapacity(pbHash, cbHash, 0)
if (NT_STATUS := DllCall("bcrypt\BCryptHash", "ptr", hAlgo, "ptr", 0, "uint", 0, "ptr", &pbInput, "uint", cbInput, "ptr", &pbHash, "uint", cbHash) != 0)
throw Exception("BCryptHash: " NT_STATUS, -1)
loop % cbHash
hash .= Format("{:02x}", NumGet(pbHash, A_Index - 1, "uchar"))
DllCall("bcrypt\BCryptCloseAlgorithmProvider", "ptr", hAlgo, "uint", 0)
DllCall("FreeLibrary", "ptr", hBCRYPT)
return hash
}