Jump to content

Module:RadioGatun32/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Samboy (talk | contribs) at 07:36, 14 August 2022 (Testing inside Mediawiki: Nowiki needed). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


Usage

This module calculates the RadioGatún[32] sum for a given string, returning it in a format suitable for showing a demonstration sum on a Wikipedia page. RadioGatún is a cryptographic hash function from 2006 which remains, as of 2022, unbroken.

To use:

{{#invoke:RadioGatun32|rg32|String to input}}

Or with the template (at Template:RadioGatun32):

{{RadioGatun32|String to input}}

If there is {{Background color|#888|d}} in the string to input, the calculated sum will be based on a string without the background color formatting.

Examples

{{#invoke:RadioGatun32|rg32|Hello, world}}

Will create this output:

RadioGatun[32]("Hello, world") =
D91BBD22BE5D01F091F26A16704CDA0E165588E025D9BA6619C5B01550756349

Here is the computed output:

RadioGatun[32]("Hello, world") =
D91BBD22BE5D01F091F26A16704CDA0E165588E025D9BA6619C5B01550756349

We can have background colors:

{{#invoke:RadioGatun32|rg32|{{Background color|#ff8c00|Li}}{{Background color|#004dff|fe}}!}}

Shows us this:

RadioGatun[32]("Life!") =
80E706E851DCDE1170452EEC6EAD24F40E63B9A07B86D8D32053A1237835E03D

The above should look exactly like this:

RadioGatun[32]("Life!") =
80E706E851DCDE1170452EEC6EAD24F40E63B9A07B86D8D32053A1237835E03D

The computed sum will be for the string Life!, as can be seen in the following:

RadioGatun[32]("Life!") =
80E706E851DCDE1170452EEC6EAD24F40E63B9A07B86D8D32053A1237835E03D

The above should look like this:

RadioGatun[32]("Life!") =
80E706E851DCDE1170452EEC6EAD24F40E63B9A07B86D8D32053A1237835E03D

The background colors do not affect the computed RadioGatun[32] sum.

Testing

Testing inside Mediawiki

To test this in Mediawiki, go to Module:RadioGatun32/test, click on "edit this page", then in the debug console at the bottom, type in print(p.test()). One should see "All RadioGatun[32] test vectors pass".

Another way to test this is to add {{#invoke:RadioGatun32/test|test}} to a page; wherever RadioGatun32/test is invoked, it should show "All RadioGatun[32] test vectors pass".

Testing outside Mediawiki

This module can either be run as a Mediawiki Lua module, or as a standalone Lua script. This very same script is also available on GitHub in a repo which includes automated tests to ensure implementations of RadioGatun[32] generate correct hashes against a number of test inputs, including all official RadioGatun[32] test vectors.

To test this code, in a *NIX compatible environment like Linux, with Git and a version of Lua above 5.1 and below 5.4 (Lua 5.4 dropped bit32; a Lua 5.1 implementation with bit32 support will also work), do the following:

git clone https://github.com/samboy/rg32hash
cd rg32hash/sqa
./do.test.sh ../Lua/rg32wiki.sh

See also