• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


28 Nov, 2024

Updated at 05 Dec, 2024

Help with a Decoding and Encoding function for a Non-Random and Non-Repetitive Code Generator

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to achieve a function which generates a Code from a ID. For example the ID is 1, and the Code would always be the same, so I don’t mean to use math.random() or anything like that.
  2. What is the issue? Include screenshots / videos if possible!
    The issue is that I need a encoding and decoding function and the only issue is the decoding function, because there can be repetitives and it is hard to make a encoding function which can also be decoded.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked on the Developer Hub, but I saw people always trying to use math.random() and tick() and all that, but I want to generate a Code which is always the same, no matter the time when you generate it.

I have tried making a encoding Code function by myself, it worked good but it would be impossible to decode as I used alot of % values (sorry I don’t know what to call them).
(if you were wondering, the available letters are A-Z and 0-9, aka “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”.)

The code would also be formatted like this: ABC-DEF-GHI, and it would start from the left side and fill up (example: id : 1, code “A00-000-000”, id : 100, code “G1L-200-000”, id : 10000, code “6MV-SMZ-TL1”)

Again, the encoding function is easy but the decoding function is hard due to the repetitives.
Also another thing I don’t really want is too many same letters, for example “AAA-A41-0ZN”, so I want it to be truly random but also kinda… not. (because I said earlier that I don’t wanna use math.random() functions)

Would be nice if I could get this done or get suggestions on what encoding / decoding functions I could use

1 post - 1 participant

Read full topic