0

Similar to this question in C#: User ID obfuscation

I'm looking for a solution in VBA to obscure a long value through an encoding method and also I would need to be able to decode the number produced as well.

Community
  • 1
  • 1
Gareth
  • 5,140
  • 5
  • 42
  • 73
  • why not use a guid? also, in what context are you doing this? surely you can't be writing web apps in VBA?!?!?! – Jeremy Jan 18 '16 at 20:17
  • Check this question here: http://stackoverflow.com/q/8047094/5090027 While it doesn't have an accepted answer, there are many views presented and it seems to have just been abandoned by the OP. – Grade 'Eh' Bacon Jan 18 '16 at 20:42
  • @Jeremy No not for a web app! Couldn't thing of a worse language to use! I'm looking to obscure an (already in place) id field which is an integer hence Going to struggle to move to a guid. – Gareth Jan 18 '16 at 20:42
  • @Gareth in what type of app? excel? access? – Jeremy Jan 18 '16 at 20:47
  • @Jeremy Excel sorry. – Gareth Jan 18 '16 at 20:57
  • and where are you showing this ID? in a sheet? in a vba form? why show it, can it just be hidden, especially if it's in a column. – Jeremy Jan 18 '16 at 21:10

1 Answers1

0

I agree with the answer as stated on the referenced article: User ID obfuscation

Why not add a GUID and a lookup table?

Community
  • 1
  • 1
Brian Riley
  • 926
  • 1
  • 7
  • 12
  • As per comment above, it's an existing table with integer id's in it that I'm looking to obscure. – Gareth Jan 18 '16 at 20:43
  • I think the question is too broad to answer - if you assume that the table could hold MAX_INT and that you could have MAX_INT values in the table, then all you can do is map 1 value to another value. If you have MAX_INT values, there is no formula you can use where someone could enter a number that doesn't match something. To put that another way, if you can store 10 values, the most you can do is map each value to a different number - but 1 - 10 will always produce a valid hit on some form of data. – Brian Riley Jan 18 '16 at 21:00
  • How can it be too broad if it can't be answered? – Gareth Jan 18 '16 at 21:03
  • You never said what type of data it is, or how much of it you have. If it's a user id and you have 10 users in the system and only ever expect to get 20 users, you can obscure it with a formula that distributes the values of say 100 across MAX_INT. So is MAX_INT was 1MM, and you had a max of 100 users, you could multiply the values by 10K. If an even distribution of 1 every 10K. This may be exactly what you're looking for, or it could be way too "weak" an obfuscation. – Brian Riley Jan 18 '16 at 21:09
  • There are a lot of variables about what you're trying to do and how much space you have to work with and what happens if there's a wrong hit, to fully answer your question. – Brian Riley Jan 18 '16 at 21:09
  • Sorry might have been a bit brash yesterday. By `Long` in the op, I was referencing VBA's 32 bit signed integer. Essentially, the `Id` serves as a reference on a system to the end user. – Gareth Jan 19 '16 at 08:51