Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 256267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:00:00+00:00 2026-05-11T22:00:00+00:00

I am working on a function that takes in a series of permission strings,

  • 0

I am working on a function that takes in a series of permission strings, less than 255 characters and assigns them to an entity. Each string assigned is unique, but there are so many that dropping them into an array, serializing them and pushing into a database and pulling them out later and de-serializing them or recalculating from a query every time there is a load has been causing delay problems. Especially with inherited permissions.

So I was thinking of taking the string, generating a mask from it then OR’ing into the permissions glob. As more permissions are added continue to OR them to the glob. Then when you need to verify the permission AND the string against the glob.

The question is how to generate the mask. At first I was thinking of just hashing the string for a unique mask, however it is conceivable, but I don’t know how likely, that as more hash values are OR’ed onto the glob the potential for filling the glob in such a way that and AND test with a permission they don’t have, yet return a true value.

if($glob&&$test == $test)

The other option would be just auto-number the permission strings and have their mask be 2^auto-number. But that would limit the number of permission strings to around 64ish.

What I really want is a glob of some sort that I can pull out of a database once and associate it with the user. Then test that glob against a string or associated value representing a permission set.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:00:00+00:00Added an answer on May 11, 2026 at 10:00 pm

    I found an interesting solution but I am unsure if how logically correct it is because I am not very familiar with how PHP handles string data. I decided to cut away everything and try to do it straight without any hashing or assigning or whatnot and just do bitwise operations on strings. It seemed to work, but I am not sure I can prove my logic true enough.

    $key1 = "Access to Black Box";
    $key2 = "Managing Black Box";
    $key3 = "Nothing too see here";
    $key3a = "Nothingg B";
    $key3b = "too see";
    $glob = "";
    
    $glob = $glob | $key1;
    if(($glob & $key1) == $key1){echo "<p>Key one exists in glob: " . $glob;}
    
    $glob = $glob | $key2;
    if(($glob & $key2) == $key2){echo "<p>Key one exists in glob: " . $glob;}
    
    if(($glob & $key3) == $key3){echo "<p>Key three exists in glob: " . $glob;}
    else{echo "<p>Key three does not exists in glob: " . $glob;}
    
    $glob = $glob | $key3;
    if(($glob & $key3) == $key3){echo "<p>Key three exists in glob: " . $glob;}
    
    if(($glob & $key3a) == $key3a){echo "<p>Key three a exists in glob: " . $glob;}
    
    if(($glob & $key3b) == $key3b){echo "<p>Key three b exists in glob: " . $glob;} 
    else{echo "<p>Key three b does not exists in glob: " . $glob;}
    

    Outputs:

    Key one exists in glob: Access to Black Box
    Key two exists in glob: Mcoew{nwobnmckkbox
    Key three does not exists in glob: Mcoew{nwobnmckkbox
    Key three exists in glob: Oomowoomsooboze
    Key three a exists in glob: Oomowoomsooboze
    Key three b does not exists in glob: Oomowoomsooboze
    

    So this works, but what would I be looking at collision wise? With key3a I showed that a string that has a combination of characters that match positions with characters in other keys I can get a false positive. But can I get around it with strict rules on the permission strings? Each resource type is named and each resource type has a limited number of associated permissions. So something like “Blog….Write Post”, “Blog…Publish Post”, “Blog….Moderate Post”, “Podcast…….Upload”, “Podcast…….Publish” to compensate for the increasing probability of a collision since string length has little impact on PHP’s speed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a function that takes filepaths and dices them up into smaller
I'm working with a PHP function that takes a string and converts all of
Hey, I was working with a PHP function that takes multiple arguments and formats
I am working with datetime objects in python. I have a function that takes
I'm working on a function that takes the stage mouse coordinates in Flash AS3
I'm working on function, that takes a select from html and replaces it with
I've got a simple function that takes a List parameter. While working with it,
I'm working on a function that is too complicated (processor) so I embedded part
I am working on a function that accepts a JSON object as a parameter.
I'm working on a function that handles events from a number of buttons and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.