Git Product home page Git Product logo

laravel-hashids's Introduction

Hashids for Laravel 4

Latest Stable Version Total Downloads

This package uses the classes created by hashids.org

Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not want to expose your database ids to the user.


Installation

To get the latest version of Hashids simply require it in your composer.json file.

"torann/hashids": "1.0.*@dev"

You'll then need to run composer install to download it and have the autoloader updated.

Once Hashids is installed you need to register the service provider with the application. Open up app/config/app.php and find the providers key.

'Torann\Hashids\HashidsServiceProvider'

There is no need to add the Facade, the package will add it for you.

Publish the config

Run this on the command line from the root of your project:

$ php artisan config:publish torann/hashids

This will publish Hashids' config to app/config/packages/torann/hashids/.

Usage

Once you've followed all the steps and completed the installation you can use Hashids.

Encodeing

You can simply encode a single id:

Hashids::encode(1); // Returns Ri7Bi

or multiple..

Hashids::encode(1, 21, 12, 12, 666); // Returns MMtaUpSGhdA

Decodeing

Hashids::decode(Ri7Bi);

// Returns
array (size=1)
0 => int 1

or multiple..

Hashids::decode(MMtaUpSGhdA);

// Returns
array (size=5)
0 => int 1
1 => int 21
2 => int 12
3 => int 12
4 => int 666

Changelog

1.0.0

  • Several public functions are renamed to be more appropriate:

    • Function encrypt() changed to encode()
    • Function decrypt() changed to decode()
    • Function encryptHex() changed to encodeHex()
    • Function decryptHex() changed to decodeHex()

    Hashids was designed to encode integers, primary ids at most. Hashids is the wrong algorithm to encrypt sensitive data. So to encourage more appropriate use, encrypt/decrypt is being "downgraded" to encode/decode.

  • Version tag added: 1.0

  • README.md updated

All credit for Hashids goes to Ivan Akimov (@ivanakimov), thanks to for making it!

laravel-hashids's People

Contributors

torann avatar

Watchers

 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.