Hashing Md5 using scripting

Hi everyone
I am trying to create a hash of a record using md5. I am fairly new to script but I am willing to learn. does anyone have an idea of how to do that?

Thank you

There are at least six pathways any recommendation could lead; help me find the right pathway by sharing what you would do with a hashed record.

Hi Bill, sorry I just saw your message.
Yes so what i want to do is the following
I have a table with a concatenated field. I would like to generate a hash for the concatenated field

The table looks like something like this:

<iframe class="airtable-embed" src="https://airtable.com/embed/shr9DMj7PirI4dY6e?backgroundColor=teal&viewControls=on" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>

Sorry i don’t know how to copy a view of the base.

The concatenated value is to be hashed on the last column.

Any idea how this could be achieved?
Thanks

Right, I understand what you would do to the target field. I don’t understand the reason for doing so.

If you are trying to conceal a password, for instance, my advice would be very different from using this approach to generate an immutable key value.

My advice is gated by the objective.

1 Like

actually, the purpose is to produce a hash that will be added to a url to produce a unique url for SSO.
I am happy to concatenate the differente values, no pb there, my issue is about hashing a parameter using md5
I can integrate that hash to the url parameter. I hope the objective is clearer. Thanks

Okay, and is the purpose to encode the URL to avoid all of the issues with a URL parameter that is unruly and unable to meet the requirements of HTTP addresses? If so, why not simply encode the parameter?

In any case, computing an MD5 can be done with a script action, although not recommended because MD5’s are pretty intensive. The better approach might be to use a Script Block like this:

/*

   ***********************************************************
   ScriptBloqs - MD5
   Copyright (c) 2021 by Global Technologies Corporation
   ALL RIGHTS RESERVED
   ***********************************************************
   
*/

output.markdown('# MD5 Example');

// load the md5 library
// not included because of space limitations...

// get the name of the table
let table = base.getTable("Airdrop");

// get the records from this table
let records = await table.selectRecordsAsync();

// Update the records
for (let record of records.records) {

    if (record.getCellValue("MD5 Source"))
    {

        output.inspect(record.getCellValue("MD5 Source"));

        // compute the md5 value
        thisMD5 = MD5(record.getCellValue("MD5 Source"));
        output.markdown("MD5: " + thisMD5);

        await table.updateRecordAsync(record, {
            "MD5 Target" : thisMD5,
        });

    }
}

Note that this code is not functional until you include this library at the top of the script itself. Note - if you obfuscate the library with a tool like this, the performance will double.

When this block is executed on this example data, you will get the MD5 values as desired.