Git Product home page Git Product logo

bits's Introduction

BitCollection

Inspired by BitVector32 and BitArray, I created something of a cross between the two. ๐Ÿ‘น

I've got a bad feeling about this.

  • Princess Leia, Obi-Wan Kenobi, Anakin Skywalker, Luke Skywalker, C-3PO, Han Solo, BB-8, Lando Calrissian

Pull requests welcome, use at your own risk, the Star Wars universe has warned you.

The hope for this was to create an efficient (small), yet well defined, JWT claim that could store user permissions or other flags. For instance when base64 encoding 128 different flags (bits) it can be stored in a user claim as short as 22 characters. If each resource knows that bit 7 is the permission to create new users you can use the claim to enable and disable user controls to without needing to make calls to the user permissions store, etc.

Feel free to fork or submit a pull request if you feel you have an improvement. If you find a bug file an issue and I'll try to respond in a timely manner.

BitFlags

Given a set of key value pairs that consist of numeric values only, encode them into an arbitrary number of bits. The number of bits allocated to the key and value should be defined in the first byte.

          K1          V1 K2          V2
 01   02  |           |  |           | 
|--| |--| KKKK KKKK KKVV KKKK KKKK KKVV
1001 0001 0000 0000 0000 0000 0000 0000
| 9| | 1|
  |    |
  |    1 + 1 bits or 4 possible values
  9 + 1 bits or 1024 possible keys
---

01 - indicates the bit length of the key, 1 to 16 bits

02 - indicates the bit length of the value, 1 to 16 bits

bits's People

Contributors

gonkers avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.