Simple code and decode of a string

Posted by OctavioOlguin on 13-Jun-2019 13:51

Greetings.

I'm in search for a simple algorithm for encode and decode  simple strings like "005-00001234".

Does anybody seen something quick and dirty abl for that purpose?

(it's for customer points accumulation based on sale receipt number, so it should be short enough for the user to post it on an app)

TIA

Jorge

Posted by gus bjorklund on 13-Jun-2019 16:10

I agree, octavio. bas 64 is cumbersome for typing

why not generate a random number and print that on the ticket along with customer number. then store random number in customer record. when customer enters the matching number, you know he has the ticket.

All Replies

Posted by Peter Judge on 13-Jun-2019 14:02

What's the decoding you're after?
 

Posted by gus bjorklund on 13-Jun-2019 14:24

maybe the 4GL functions base64-encode () and base64-decode () will suit you.

Posted by OctavioOlguin on 13-Jun-2019 15:37

Thanks for answering!!!

[mention:9e4ee96fac634b8f91b580e1fb4f7e71:e9ed411860ed4f2ba0265705b8793d05] What I'm trying to do is validating that a customer has a legit sales receipt, as this will accumulate points that later he or she can cash-out.  So I'm devising some way to encode ticket number and total amount and stuff, print on purchase ticket, and then on appserver decode and validate the existence of that ticket.  What I want to avoid is a customer cashing out his ticket and the next 100 numbers..

[mention:9617a07f61934bc98f6fccb3b7fabfae:e9ed411860ed4f2ba0265705b8793d05] I had checked that functions (and other solutions) before posting... and I find it's a lot cumbersome for a customer to type all digestion characters to validate...

Do you agree?

Thanks again!!!

Posted by ChUIMonster on 13-Jun-2019 15:51

Simply validating that a sales receipt (or other numeric id) is (probably) legitimate can be done with a checksum.  There are many algorithms for that with varying degrees of usefulness.

Posted by ChUIMonster on 13-Jun-2019 15:52

Simply validating that a sales receipt (or other numeric id) is (probably) legitimate can be done with a checksum.  There are many algorithms for that with varying degrees of usefulness.

Posted by gus bjorklund on 13-Jun-2019 16:10

I agree, octavio. bas 64 is cumbersome for typing

why not generate a random number and print that on the ticket along with customer number. then store random number in customer record. when customer enters the matching number, you know he has the ticket.

Posted by OctavioOlguin on 13-Jun-2019 16:32

thanks.

I was thinking to be able to encode-decode as I don't have customer id or otherwise any way to identify the holder of ticket.  I want to encode Ticket number and amount, and then descramble that to accumulate, and I'll get a this moment the cell number as a query (/rest?parameter=telNumbr ), so I'll add to that number from now on.

This thread is closed