bdittmar
24th January 2009, 15:28
Hello,
has anybody ever developed a checksum routine in BaaN 4GL like the appended C-Source ?

Regards

george7a
28th January 2009, 13:09
Hi,

Can you elaborate on this issue?

- George

bdittmar
28th January 2009, 15:12
Hi,

Can you elaborate on this issue?

- George

Hello George,

based on a given Hashtable a 16 Bit CRC (Checksum) should be built.

Input : variable like 1234567890 or 0901102340 ....
Output : 16 Bit CRC based on the Hashtable.

for i = 0 to length of input

like given c.code : crc = hashtable(crc "bit.shift.right 8" and 0xFF) XOR (crc "bit.shift.left 8) XOR (i)

if crc = 0 then
crc = 0xA0A0
endif

I hope i've explaint it the right way (Not 100% sure)

My main question is, has somebody done something like this in 4GL and are able to provide me with some hints.

Regards

NPRao
28th January 2009, 19:07
Bernd,

Did you check these topics - Secure Hash Algorithm overview (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sha_sha_overview), Secure Hash Algorithm synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sha_sha_synopsis)

bdittmar
29th January 2009, 14:13
Bernd,

Did you check these topics - Secure Hash Algorithm overview (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sha_sha_overview), Secure Hash Algorithm synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sha_sha_synopsis)

Hello Prashanth,
thank's for your answer. But i need this CRC16 bcause another independet Software must build the same chechsum, therefore the logic and building must be identical in both environments.

Regards

NPRao
29th January 2009, 21:07
I never used this but there is a function in the Tools Standard Library ttstp_stddll -

string get.crc.16( const string input_string(), [ long len_input_string ] )

Desc: This function calculates a CRC16 code for a given string
Originally this function has been written to create a unique ID for an application lock

In: input_string: the string for which the CRC16 must be computed
len_input_string: the length of the string (needed when using a string containing chr$(0))
Pre: input_string must be filled
Post: function returns a hexadecimal value via a string.

return Values:
Alternatively, you can also use the Unix command -

$ man cksum

cksum(1) cksum(1)

NAME
cksum - print file checksum and sizes

SYNOPSIS
cksum [file ...]

DESCRIPTION
The cksum command calculates and prints to standard output a checksum for each named file, the number of octets in the file and the filename.

cksum uses a portable algorithm based on a 32-bit Cyclic Redundancy Check. This algorithm finds a broader spectrum of errors than the 16-bit algorithms used by sum (see sum(1)). The CRC is the sum of the following expressions, where x is each byte of the file.

x^32 + x^26 + x^23 +x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7
+ x^5 + x^4 + x^2 + x^1 + x^0

The results of the calculation are truncated to a 32-bit value. The number of bytes in the file is also printed.

Standard input is used if no file names are given.

cksum is typically used to verify data integrity when copying files between systems.

EXTERNAL INFLUENCES
Environment Variables
LANG determines the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_) do not specify a locale. If LANG is not set or is set to the empty string, a default of "C" (see lang(5)) is used. LC_CTYPE determines the locale for interpretation of sequences of bytes of text data as characters (e.g., single- verses multibyte characters in arguments and input files).

LC_MESSAGES determines the language in which messages are displayed.

If any internationalization variable contains an invalid setting, cksum behaves as if all internationalization variables are set to "C".
See environ(5).

RETURN VALUE
Upon completion, cksum returns one of the following values:

0 All files were processed successfully.
>0 One or more files could not be read or another error
occurred.

Hewlett-Packard Company - 1 - HP-UX Release 11i: November 2000

cksum(1) cksum(1)

If an inaccessible file is encountered, cksum continues processing any remaining files, but the final exit status is affected.

SEE ALSO
sum(1), wc(1), pdf(4).

STANDARDS CONFORMANCE
cksum: XPG4, POSIX.2

Hewlett-Packard Company - 2 - HP-UX Release 11i: November 2000