GithubHelp home page GithubHelp logo

unique-codes's People

Contributors

bart-kuenen-nextapps avatar gdebrauwer avatar yinx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unique-codes's Issues

Deprecated function: PHP 8.1

  • Package version: 2.0.0
  • PHP version: 8.1

Description:

Deprecated function: Implicit conversion from float 222886.09677419355 to int loses precision in NextApps\UniqueCodes\UniqueCodes->encodeNumber() (line 227 of…/vendor/nextapps/unique-codes/src/UniqueCodes.php).

Code in UniqueCodes:227 generates a float value. This will be cast to interger for using as array key.

Steps To Reproduce:

Just generate a code into a PHP 8.1 environment.

Hotfix

Cast $digit into a integer on line UniqueCodes:229

    protected function encodeNumber(int $number)
    {
        $string = '';
        $characters = $this->characters;

        for ($i = 0; $i < $this->length; $i++) {
            $digit = $number % strlen($characters);

            $string = $characters[(int)$digit].$string;

            $number = $number / strlen($characters);
        }

        return $string;
    }

Generated codes look like they are being padded to reach requested string length

  • Package version: 2.0.0
  • PHP version: 8.0

Description:

Generated codes prepend the first character of the character map to fill the generated code to the requested length - or so it looks, I'm no mathematician, and thus cannot offer any help in solving it.

Steps To Reproduce:

(new \NextApps\UniqueCodes\UniqueCodes())->setObfuscatingPrime(30402457)->setMaxPrime(25964951)->setCharacters('rn5ze6xatdkv9picsh10fm8g')->setLength(16)->generate(1, 100, true);

Output:

[
     "rrrrrrrrrrrpdrr5",
     "rrrrrrrrrrn51rre",
     "rrrrrrrrrrnszrrx",
     "rrrrrrrrrr569rrt",
     "rrrrrrrrrr51mrrk",
     "rrrrrrrrrrrnghgp",
     "rrrrrrrrrrrcthgc",
     "rrrrrrrrrrnehhgh",
     "rrrrrrrrrrn15hg0",
     "rrrrrrrrrr5avhgm",
     "rrrrrrrrrr5ffhgg",
     "rrrrrrrrrrrzgvg5",
     "rrrrrrrrrrrhtvge",
     "rrrrrrrrrrnxhvgx",
     "rrrrrrrrrrnf5vgt",
     "rrrrrrrrrr5dvvgk",
     "rrrrrrrrrr58fvg9",
     "rrrrrrrrrrr6g68c",
     "rrrrrrrrrrr0t68h",
     "rrrrrrrrrrnth680",
     "rrrrrrrrrrn8568m",
     "rrrrrrrrrr5vv68g",
     "rrrrrrrrrrzrf6gn",
     "rrrrrrrrrrra8g8e",
     "rrrrrrrrrrrmag8x",
     "rrrrrrrrrrnksg8t",
     "rrrrrrrrrr5rng8k",
     "rrrrrrrrrr5pkg89",
     "rrrrrrrrrrz50g8i",
     "rrrrrrrrrrrd8hmh",
     "rrrrrrrrrrrgahm0",
     "rrrrrrrrrrn9shmm",
     "rrrrrrrrrr55nhmg",
     "rrrrrrrrrr5ckh8n",
     "rrrrrrrrrrze0h8z",
     "rrrrrrrrrrrv8vmx",
     "rrrrrrrrrrnnavmt",
     "rrrrrrrrrrnisvmk",
     "rrrrrrrrrr5envm9",
     "rrrrrrrrrr5hkvmi",
     "rrrrrrrrrrrrp6fh",
     "rrrrrrrrrrrp86f0",
     "rrrrrrrrrrnza6fm",
     "rrrrrrrrrrnss6fg",
     "rrrrrrrrrr5xn6mn",
     "rrrrrrrrrr50k6mz",
     "rrrrrrrrrrr59gfx",
     "rrrrrrrrrrrcmgft",
     "rrrrrrrrrrn6xgfk",
     "rrrrrrrrrrn1cgf9",
     "rrrrrrrrrr5trgfi",
     "rrrrrrrrrr5mdgfs",
     "rrrrrrrrrrre9h00",
     "rrrrrrrrrrrhmh0m",
     "rrrrrrrrrrnaxh0g",
     "rrrrrrrrrrnfchfn",
     "rrrrrrrrrr5krhfz",
     "rrrrrrrrrr5gdhf6",
     "rrrrrrrrrrrx9v0t",
     "rrrrrrrrrrr0mv0k",
     "rrrrrrrrrrndxv09",
     "rrrrrrrrrrn8cv0i",
     "rrrrrrrrrr59rv0s",
     "rrrrrrrrrrzndv01",
     "rrrrrrrrrrrt961m",
     "rrrrrrrrrrrmm61g",
     "rrrrrrrrrrnvx60n",
     "rrrrrrrrrr5rc60z",
     "rrrrrrrrrr5ir606",
     "rrrrrrrrrrzzd60a",
     "rrrrrrrrrrrkvg1k",
     "rrrrrrrrrrrgfg19",
     "rrrrrrrrrrnp6g1i",
     "rrrrrrrrrr55ig1s",
     "rrrrrrrrrr5cgg11",
     "rrrrrrrrrrz6tg1f",
     "rrrrrrrrrrr9vhhg",
     "rrrrrrrrrrnnfh1n",
     "rrrrrrrrrrnc6h1z",
     "rrrrrrrrrr5eih16",
     "rrrrrrrrrr5hgh1a",
     "rrrrrrrrrrrn5vhk",
     "rrrrrrrrrrrivvh9",
     "rrrrrrrrrrnzfvhi",
     "rrrrrrrrrrnh6vhs",
     "rrrrrrrrrr5xivh1",
     "rrrrrrrrrr50gvhf",
     "rrrrrrrrrrrz56sg",
     "rrrrrrrrrrrsv6hn",
     "rrrrrrrrrrn6f6hz",
     "rrrrrrrrrrn066h6",
     "rrrrrrrrrr5ti6ha",
     "rrrrrrrrrr5mg6hd",
     "rrrrrrrrrrr6ngs9",
     "rrrrrrrrrrr1kgsi",
     "rrrrrrrrrrna0gss",
     "rrrrrrrrrrnmegs1",
     "rrrrrrrrrr5kpgsf",
     "rrrrrrrrrr5g8gs8",
     "rrrrrrrrrrranhsn",
   ]

Parameters in config file?

  • Package version: n/a
  • PHP version: n/a

Description:

Currently, I believe a developer must specify both primes, plus the list of characters, plus any other parameters they wish to supply, each time they call UniqueCodes().

I use Laravel and I'd love to be able to put all those config items in a config file, so that I don't need to supply them in the main body of my code.

Does that sound like a good idea? Would the project maintainers be keen to see a PR, if I put one together?

Steps To Reproduce:

n/a

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.