delphi - Crc16 To String -


i can convert string crc16 need convert crc16 string.is possible?

function tform1.crc_16(icerik: string): word; var   valuehex: word;   i: integer;   crc: word; begin   crc := 0;   := 1 length(icerik)   begin     valuehex := ((ord(icerik[i]) xor crc) , $0f) * $1081;     crc := crc shr 4;     crc := crc xor valuehex;     valuehex := (((ord(icerik[i]) shr 4) xor lo(crc)) , $0f);     crc := crc shr 4;     crc := crc xor (valuehex * $1081);   end;   crc_16 := (lo(crc) shl 8) or hi(crc); end; 

this function convert string crc16 .

no it's not possible, due pigeonhole principle. in order able convert crc16 string need have mapping function set of crc16 values set of string values.

since there 65536 (216) possible crc16 values, , there considerably more 65536 possible values string can have, it's not possible define 1-to-1 correspondence, converting crc16 string impossible.

to put way, string crc16 function many-to-one: many different strings map same crc16 value (i.e. placed in same "pigeonhole"). if start crc16 value, how know of many possible strings original string?

one special case exception if string allowed have set of possible values, , each value in set maps unique crc16 value. in case function reversible, long know set of possible string values.