STW Clever types - ...
 

Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop

[Closed] STW Clever types - random code generator - anyone??

16 Posts
16 Users
0 Reactions
458 Views
Posts: 0
Free Member
Topic starter
 

Does any of you guys know of a system/app/program that could randomly generate a code that could then be cross referenced back to an 'original' code?

example:

true code
ADXWW/120/XX/DD

random code generated would then when searched by us would reveal the original true code??

Hope this makes sense


 
Posted : 14/02/2020 2:07 pm
Posts: 17301
Free Member
 

Is this for you or your brother in-law?


 
Posted : 14/02/2020 2:12 pm
 Drac
Posts: 50446
 

Paging Chewkw.


 
Posted : 14/02/2020 2:13 pm
Posts: 10560
Full Member
 

You could do this in Python in <30 mins.

Tabulate your original codes in Excel and save as a CSV, Start Python, Import Numpy read the CSV into Python as an array, write a statement which reads the array and when a value without a corresponding value (next column) is found, it triggers the random number generator within a range of values and assigns those values to the array. Write the file back.


 
Posted : 14/02/2020 2:19 pm
Posts: 2590
Full Member
 

If it doesn't need to be in the same format you could just use a GUID generator and store that alongside your real data.


 
Posted : 14/02/2020 2:20 pm
Posts: 77675
Free Member
 

Does it need to be secure? Ie, do you want it so only you can reverse it to get the original?

If so you've basically just described encryption.


 
Posted : 14/02/2020 2:34 pm
 IHN
Posts: 19854
Full Member
 

BEYXX/231/YY/EE

You're welcome


 
Posted : 14/02/2020 2:36 pm
Posts: 0
Free Member
 

Substitution. You have missed the random requirement.


 
Posted : 14/02/2020 9:56 pm
Posts: 1226
Full Member
 

I think it depends on how the recovery of the original code would need to work.

I think there are two approaches:

1. Original code and random code are somehow cross-referenced in a database or similar. If this is acceptable, any pseudorandom number generator would do, so long as you ensure you avoid clashes in the database.

2. Original code is algorithmically derived from the random code. You could do that with some kind of reversible/symmetric function. It could be a crypo function as Cougar says.

If you want the mapping of original code to random code to be secure to some degree, you will need to consider this carefully in your approach.


 
Posted : 14/02/2020 10:26 pm
Posts: 77675
Free Member
 

Actually, I'm slipping in my old age.

You'be provided us with a solution and asked about how to implement it. This rather begs the question, what problem is this solution intended to solve?


 
Posted : 14/02/2020 10:33 pm
Posts: 0
Free Member
 

Actually, I’m slipping in my old age.

You can get pads for that. With or without wings.
HTH


 
Posted : 15/02/2020 7:21 am
Posts: 1106
Free Member
 

Could VB Excel do this? Generates random set of characters generated and vlookup or search or similar to find the true code?


 
Posted : 15/02/2020 9:49 am
Posts: 3202
Free Member
 

You want two-way encryption using a cypher key of your choice.

https://codebeautify.org/encrypt-decrypt


 
Posted : 15/02/2020 10:12 am
Posts: 214
Full Member
 

Without knowing about you particular use case, what are these codes used for, it's hard to give a definitive answer. You could look at one way hashing, the openssl library is available on most platforms and provides sha3 secure one way hashes.

If a raw hash is too much data you could use an agreed subset of the hash, say you want a 6 character code take characters 1,2,3,5,8,13 say each time. This does increase the risk of collision, two values giving the same code.

The advantage of this approach is that you don't have to store the codes, they can always be regenerated.

But a lot of this depends on volumes and what your planning to actually do!


 
Posted : 15/02/2020 10:20 am
Posts: 8672
Full Member
 

.


 
Posted : 17/02/2020 8:24 am
Posts: 91095
Free Member
 

Also, what platform are you working with?

The OP said random code, so if that's what he meant then it's not derived from the original code. It'd have to be cross-referenced in a DB.


 
Posted : 17/02/2020 1:57 pm
Posts: 6897
Full Member
 

Requirement sounds more like a tokenisation requirement than encryption.

https://www.clearent.com/insight/tokenization-vs-encryption/


 
Posted : 17/02/2020 2:17 pm