Need coldfusion version of php's sha1 and mb_convert_encoding

384 Views Asked by At

Does anyone know the coldfusion equivelent for this php code?

    $calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8"));

    $calcedVerify = strtoupper(substr($calcedVerify,0,8));

Thanks!

1

There are 1 best solutions below

0
On
<cfset calcedVerify = Hash(pop ,"SHA-1", "UTF-8")>
<cfset calcedVerify = Left(calcedVerify, 8)>

Note: The hexadecimal hash returned is already in uppercase.

SHA-1 should be available in Standard Edition according to Adobe ColdFusion 9 Web Application Construction Kit even though the hash() doc said otherwise

substr() ~= Mid() but CF index starts from 1 instead of 0.

strtoupper() == ucase()

mb_convert_encoding() ~= CharsetDecode()