Calculate the the CRC-16-CCITT in Zoho creator function

Calculate the the CRC-16-CCITT in Zoho creator function

I need a custom function in Zoho creator to calculate CRC-16-CCITT with
polynom  (hex): 1021
Initial value  (hex)      :FFFF

the function is use to calculate CRC-16 by returning a 4-digit Hex value with a string input. like input the string of "00020101021126270012hk.com.hkicl020782419455204000053033445802HK5902NA6002HK6304" it returns "6674" (hex)
or 
"00020101021226430012hk.com.hkicl0418wsdinfo@wsd.gov.hk060115204000053033445406174.605802HK5902NA6002HK62150111979072028366304"  returns "65CB" (hex)

There are calculator in web like this one http://www.zorc.breitbandkatze.de/crc.html , the source code of this page can calculate the CRC16, but I have no idea how to convert is into the Zoho CS5 code for the usage in the Custom Function.  Can anyone help please!! Thank you so much