PHP md5 conversion to Coldfusion for CloudTrax -


i converting php sample code cloudtrax (it's wifi access point) coldfusion. having issue line of code. 2 data types concatenated. have tried multiple times cannot work. not sure php doing internally, or if converting data internally make work.

$hexchall <- binary

$secret <- string

php

$crypt_secret = md5($hexchall . $secret, true) 

cfm

binarydecode(lcase(hash(hexchall&secret,"md5")),"hex") 

coldfusion responds: bytearray objects cannot converted strings. if use charsetencode() on binary, no longer matches output of php.

i not php guy, pretty sure cannot concatenate 2 variables on cf side. not unless both values share same encoding. instead, try decoding both values binary, merging them, hashing merged array. suspect php doing internally.

the exact code vary depending on encoding of strings, should work in cf10+.

cf:

// decode both values binary  hexchall = binarydecode("546869732069732062696e617279", "hex"); secret = charsetdecode("this secret", "utf-8"); // merge binary single array // note: arrayappend not work these values util = createobject("java", "org.apache.commons.lang.arrayutils"); mergedbytes = util.addall(hexchall, secret); // finally, hash binary crypt_secret = lcase(hash( mergedbytes, "md5")); writedump(crypt_secret); 

php:

$hexchall = hex2bin("546869732069732062696e617279");  $secret = "this secret"; $crypt_secret = md5($hexchall. $secret, true); print_r(bin2hex($crypt_secret)); 

result:

2e7840389862afdc913c51df5f394125 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -