Eve Online, a game I used to play, had an interesting permissions system for account interactions with other apps.The permissions encompassed dozens of individual permissions, each under a category (which may or may not have been relevant to the resulting hash)The interesting thing is that the entire permission state of the account could be saved as one resulting string, or hash, which translated in turn, back to a detailed set of individual permissions. What algorithm or system is responsible for such an ingenious and compressed way of signifying permissions?
How to represent complex permissions system in single hash or set of characters?
algorithms;permissions
Assuming the permissions were binary and that the set of permissions was predetermined and rarely changed, a bitfield would be a good starting point. Pair each bitfield (with a fixed length) with an identifier for the app (also of fixed length, perhaps a GUID) and you've got a simple record type that can then be repeated for each app. Then just convert that into Base64 or some similar way to encode pure binary in readable text and you're done.Specifically, a bitfield uses a single bit for each boolean value, masking off bits within bytes (or words) with efficient bitwise operators in order to set or read those bits. This combines efficient memory usage with fast operators at the expense of somewhat awkward manipulation.