Questions tagged [hashids]

Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers.

Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers.

It converts numbers like 347 into strings like “yr8”, or array of numbers like [27, 986] into “3kTMd”.

You can also decode those ids back. This is useful in bundling several parameters into one or simply using them as short UIDs.

Hashids is available in JavaScript, Ruby, Python, Java, Scala, PHP, Perl, Swift, Clojure, Objective-C, C, C++11, Go, Erlang, Lua, Haskell, Elixir, Rust, ColdFusion, Groovy, Kotlin, Nim, VBA, ActionScript, CoffeeScript, Bash and for Node.js & .NET

65 questions
32
votes
5 answers

Fast hash for strings

I have a set of ASCII strings, let's say they are file paths. They could be both short and quite long. I'm looking for an algorithm that could calculate hash of such a strings and this hash will be also a string, but will have a fixed length, like…
Anthony
  • 12,407
  • 12
  • 64
  • 88
21
votes
2 answers

get hash from strings, like hashids

Using the package hashids, I can obtain hashes (with encode and decode) from numbers. var Hashids = require("hashids"), hashids = new Hashids("this is my salt", 8); var id = hashids.encode(1); Is there a similar package to…
JuanPablo
  • 23,792
  • 39
  • 118
  • 164
6
votes
2 answers

Use Hashids library to hash ids on Laravel eloquent collection

I'm grabbing a set of tasks from a database as an eloquent collection, then I'm sending the collection to my view where I do a foreach. No problems here. Except, I need to reference the task id in my view (URL action, etc). But I obviously don't…
Mike Barwick
  • 6,288
  • 6
  • 51
  • 76
4
votes
2 answers

Implement hashid in django

I've been trying to implement hashids in django models. I want to acquire hashid based on model's id like when model's id=3 then hash encoding should be like this: hashid.encode(id). The thing is i can not get id or pk until i save them. What i have…
Zorig
  • 585
  • 1
  • 10
  • 26
4
votes
3 answers

Using vinkla/hashids package in Laravel 5.2

I am using vinkla/hashids and i have followed the following steps composer require vinkla/hashids Add the service provider to config/app.php in the providers array If you want you can use the facade. Add the reference in config/app.php to your…
Awais Mushtaq
  • 633
  • 1
  • 10
  • 23
4
votes
1 answer

Using vinkla/hashids package in Laravel 5.2 to obsfucate id's in URL's

I have installed and configured the latest version (2.3.0) of vinkla/hashids on laravel 5.2. I'm unsure how to implement its functionality on my URL routes. I want to obsfucate all id attributes which are displayed in my URL routes. For example-…
user4074875
  • 146
  • 2
  • 13
3
votes
1 answer

Javascript. Uncaught TypeError: Hashids is not a constructor

Running the code from the tutorial at https://www.npmjs.com/package/hashids