Coder Social home page Coder Social logo

hashids / hashids.github.io Goto Github PK

View Code? Open in Web Editor NEW
205.0 12.0 34.0 5.4 MB

This is the old Hashids website. It is no longer maintained and has migrated over to Sqids.

Home Page: https://sqids.org

JavaScript 0.39% HTML 97.58% SCSS 2.03%
hashids

hashids.github.io's Introduction

Website documentation for Hashids.

How to update

Get Node.js, Grunt. Be sure you have Sass and Handlebars.js installed.

This is a static website that auto-generates pages for different implementations. There's two main files to update:

src/data.json
src/template.html

data.json contains majority of the implementation data that populates the site. template.html is the template.

Run the following in your git repo:

npm run production

This will keep watching your files for changes and updating whatever's needed. When done, git push your changes.

Shoutouts

Hashids website either uses or is built with the following. Muchas gracias to their respective creators for making these:

Node - Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications.

npm - Node.js package manager

Grunt - The JavaScript Task Runner

Handlebars.js - Minimal Templating on Steroids

Sass - Syntactically Awesome Style Sheets

Mouapp - The missing Markdown editor for web developers

highlight.js - Syntax highlighting for the Web

Font Awesome - The iconic font and CSS toolkit

Octodex - Github octocats

FlexSlider - An awesome, fully responsive jQuery slider toolkit

Google Fonts used:

  1. Leckerli One

  2. Fira Mono

hashids.github.io's People

Contributors

4kimov avatar alco avatar antimon2 avatar barryvdh avatar fanweixiao avatar ivanakimov avatar jacquev6 avatar jd327 avatar johnnycrazy avatar kennethanceyer avatar laserpants avatar leprosus avatar niieani avatar speps avatar tmorehouse avatar tomchiverton avatar tzvetkoff avatar vinkla 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  avatar  avatar  avatar  avatar  avatar  avatar

hashids.github.io's Issues

.NET -- bump up to 1.0

Hey Markus,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog (which is not much).

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so it's cleaner without it. Redirects still work tho (www -> non).

If you have any issues with the site (#4) or any issues in general, just ping :]

Groovy -- bump up to 1.0

Hey Chad,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog (which is not much).

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so it's cleaner without it. Redirects still work tho (www -> non).

Good job following up with that Grails plugin btw, as soon as I saw it on Twitter, I added it to the list @ http://hashids.org/groovy/

If you have any issues with the site (#4) or any issues in general, just ping :]

Decrypting Hash key

hello, I have tried to make my long url to shorten with this useful library but I have a issue about decrypting hashing data?
please can you share any sample or information regarding issue?
Regards
Thanks

hash collision

Hi, I'm using hashids to encode internal ids in our system, however I noticed a few collisions:

Hashids hashids = new Hashids( salt, 8, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" );
System.out.println(hashids.encode( 5551008 ));
System.out.println(hashids.encode( 5552196 ));

Returns:

mnbgLzGm
mnbgLZGm

Any ideas as to how this can happen? From the documentation, it seems this should be impossible. We're using the latest version (1.0.3)

Kotlin version is worse than useless

The Kotlin version is worse than useless. Looks like it was probably converted from Java a long time ago, before Kotlin reached 1.0, so it has many many compilation issues.

Anyone using this in Kotlin would be better off using the Java version. I would recommend removing the Kotlin one. Being published on Maven as a library is another big benefit of the Java version.

It looks like this ticket:

leprosus/kotlin-hashids#2

Is an attempt to whole sale fix the many many issues it has, so if you don't want to remove the Kotlin version it at least needs to be fixed.

"what not to do" section related to "Do not encode strings"

Hi there, I'm looking for a lib to hash strings as short as possible, I know this I came to see if I can find an alternative linked, suddenly read this:

Do not encode strings. We've had several requests to add this feature โ€” "it seems so easy to add". We will not add this feature for security purposes, doing so encourages people to encode sensitive data, like passwords. This is the wrong tool for that.

Basically you saying Im stupid. There could be valid reasons to try to hash a string as short as possible, right know Im trying to figure out how to have more of 1 unique id on rethinkdb, to solve the sharding problem with tables that should in theory have more than 1 unique field on the same table. I need to hash and store in memory the usernames and email, because rethinkdb cannot garantee the uniquess of the field. I came here because I was sure you can do this task correctly, basically I cannot really validate that this works correctly https://github.com/bibig/node-shorthash/blob/master/shorthash.js because I dont really understand whats doing there and I dont have the experience of other possible related problems you also found while doing this very similar library..... but instead of a solution, you telling me Im retard. Thanks

WordPress plugin broken

Just a heads up - the WordPress plugin listed under php/index.html has a couple of issues that basically make it unusable, and the author seems to be unresponsive.

Maybe it would be best to remove the link until they are fixed?

Or maybe someone knows how to get in touch with the author?

Hashids specification

The following opinion is based on my report for Go version of Hashids, see speps/go-hashids#28.

I propose Hashids to implement an API of sorts so that all implementations mentioned on the website expose same methods, so that functionality is close to 1:1 with all libraries and furthermore unconventionally I propose the Hashids also to list minimum unit tests to implement.

Reasoning:

  1. https://github.com/ivanakimov/hashids.js supports encodeHex and decodeHex and https://github.com/speps/go-hashids does not. So I am left to wonder if it should implement those or not. I understand that libraries should be able to do what they want but it would benefit to know what are the minimums. I am not absolutely sure whether strict interface could be enforced due to language differences. For example in JS encode() accepts strings, integers and arrays while in Go only int slice ([]int) is accepted. I like strictness but it could hinder language specific strengths.

  2. With minimum unit tests defined we should be fairly confident that operation across libraries is the same.

Comparing hashids for sorting?

This may be a dumb question, but can hashids be sorted and compared alphanumerically?

If x < y, is hashid(x) < hashid(y) alphanumerically?

This would be useful to know in order to sort a list of objects based on their creation order using only their hashids.

Lua -- bump up to 1.0

Hey Leif,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog (which is not much).

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so it's cleaner without it. Redirects still work tho (www -> non).

If you have any issues with the site (#4) or any issues in general, just ping :]

Swift 4.2 not decoding properly

I'm trying to implement this in Swift 4.2 but I can't seem to decode the strings properly.

I'm able to generate minHashLength 8 hash. But when I decode them and try changing say one letter at the end of the hash string, I still end up with the same hash many times.

Here's my code:

func getHashFromID (id : Int) -> String{
let hashids = Hashids(salt:mHashSalt,minHashLength: 8)
let hash : String = hashids.encode(id) ?? ""
return hash
}

func getIDFromHash (mHash : String) -> Int{
let hashids = Hashids(salt:mHashSalt, minHashLength: 8)
let numbers = hashids.decode( mHash )
print (String(format: "Decoding %@ - %d - %d - count - %d", mHash, numbers, numbers[0], numbers.count))
if (numbers.count>0){
return numbers[0]
}
return -1
}

I've implemented this successfully on Android, but the Swift version is giving me trouble in terms of decoding only.

Haxe implementation

Hi there,

I have recently ported the implementation hashids to the Haxe language which can be found here. It would be my pleasure to get it listed in the website.

Thanks.
Kevin

Lua implementation

Hi there,

I'm maintainer of a hashids.lua fork. The hashids.org site now refers to original version of hashids.lua by leihog that is not compiled with Lua version > 5.1, has a few bugs and seems abandoned by author (I have tried to contact leihog via GitHub PR and email without success).

Is it possible to add/replace the Lua implementation link to my fork repo?

Objective-C -- bump up to 1.0

Hey Jofell,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog.

Looks like Obj-C version is still at ~0.1.4, which differs a bit more from 0.3. Are you up for the update?

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so it's cleaner without it. Redirects still work tho (www -> non).

If you have any issues with the site (#4) or any issues in general, just ping :]

Demo on Codepen is broken

The check out the demo on codepen is currently broken.

ReferenceError: Hashids is not defined

I guess there should be some reference defined to the source, which is not there anymore.

BTW: The example from #39 is maybe even better than the current one?

For big numbers nothing is returned

First of all, thanks for making such a wonderful package for generating hash code, but I am experiencing an issue. When the input number is more than 200 crore ( say 3232323213 ), No data is getting returned. I am not so sure about the number where it's breaking. but it's more than 200 crore I am sure. Please look into this issue. Thanks

lower case IDs (case-insensitive)

I am thinking of using hash IDs in one of my projects.

However, the IDs must be case insensitive (all lower case). So, I was thinking of adding digit(s) (0-F) at the end after a period(.) or hyphen(-).

The number of digits will depend on length of ID and bits in digit will represent positions of capital letters in ID.

For example, if the ID generated is:
0R9ty3En
We need 8 bits to represent 8 chars. And, positions (assuming 'n' is at 0) 1 and 6 are capital. Hence, we need: 01000010

which in hex translates to: 42.

So, complete hex id would now be: 0r9ty3en-42 (all lower case that can be translated back to original easily).

Is there a better way to do this?

Implementation question, should the hashid be stored in the database instead of a PK?

Hi,

I have been reading up (a lot) about the different opinions on PK vs UUID etc., and found Hashids, which I very much prefer. However, from all the arguments in the debates on Hacker News, Reddit, StackerFlow and elsewhere, I haven't been able to determine whether the hashid should substitute the PK of the database table?

I understand that you can use hashid to simply convert, on-the-fly, back and forth using the PK, but at a bigger scale with multiple machines that's not really useful. I would like to use the hashid AS the PK, like YouTube does it.

What is the best implementation here? Still run with PK's and add a second column for storing hash'ed ID's?

What is the best approach?

Thanks and cheers.

Elixir -- bump up to 1.0

Hey Alex,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog (which is not much).

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so it's cleaner without it. Redirects still work tho (www -> non).

I also created milestones with 1.1 focusing on error handling + big integers issue. I'm also planning on experimenting around more with your idea of "outsourcing" big ints problem to other libs.

If you have any issues with the site (#4) or any issues in general, just ping :]

Moving forward to 1.0

Hey guys,

tl&dr: 1) new website 2) moving to v1 and a few adjustments 3) might be a good time to rename hashids 4) skip to the bottom to answer two questions.

I've been meaning to cleanup a few things on Hashids for a while, so finally got around to it. I created this github Hashids org and started freshening up the website a bit (http://hashids.github.io/ 90% done). The site will be on Github now (repos will of course stay where they are), so all of you can update the site/documentation as you need. I'll repoint hashids.org to it when it's ready.

New things on the website:

  • a few projects/products that use hashids (if you know of more tell me!)
  • explanation of how hashids works (finally, right?)
  • compatibility table (completely inaccurate right now, just a placeholder)
  • "are there any alternatives?" + "what not to do" sections
  • your names + links at the bottom

I think the lib is ready to move to 1.0. The algorithm is small enough and fast enough that I don't see anything else we need to update (although maybe handling of big ints later on). For now only a few minor adjustements:

  • changing naming back to encode/decode (instead of encrypt/decrypt; more appropriate + discourages people from encoding sensitive data)
  • adding tags to repos (if haven't done so already, probably only my repos anyway)
  • moving general wording towards "id" instead of "hash" in markdowns & wherever possible, which brings me to the next point

"Hashids" as the name, serves well in terms of traffic and what people search for. But it's a tiny bit misleading since hashes cannot be decrypted, and yet it's in the name - so there's some user confusion there. That's my fault. I didn't initially realize this was going to be such an issue, but the more the project grows - the more people wonder about that.

So, since 1.0 is coming, maybe this is a good time to move to a different name. This is where I need your feedback. Alex @alco has named his Elixir repo "saltie", and I thought that was really simple + easy to remember. I liked it when I saw it. (saltie.org is available too.)

Some of the disadvantages of renaming that I can think of:

  • we'd have to rename github repos to keep the links/stars/watchers/whatever (you/hashids.lang -> you/saltie.lang)
  • moving plugins/components/packages/extensions on 3rd party sites (also saltie might be taken there)
  • redirecting from hashids.org -> saltie.org (temporary problem + probably most minor issue)
  • general headache of renaming stuff :]

But the advantages are that it might be cleaner, "catchier" and easier to remember in the long run. On the other hand, a lot of people (including myself) have already gotten used to the name Hashids. So, I want to hear what you have to say. Please give feedback to the following 2 issues as we make the short jump to 1.0:

(edit: trying to figure out how to get you guys to see this issue, nvm this line. @speps @ullmark @fanweixiao @davidaurelio @peterhellberg @zakame @jofell @schoentoon @leihog @dswitzer @alco @cmaron)

  1. Do you think we should rename the project to Saltie, or keep it as Hashids?
  2. Are there any urgent changes you'd like to see in 1.0? (if not urgent, they can wait till >1.0)

Ruby -- bump up to 1.0

Hey Peter,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog (which is not much).

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so cleaner without it since it's allowed. Redirects still work tho (www -> non).

Basic responsive layout is there, but if you have any issues/changes ping me at #4 :]

JavaScript page needs more docs

Hi Team,

The JavaScript page (https://hashids.org/javascript/) has a fair amount of documentation missing that is available on its read me - example: around padding of hash ids (for greater length).

Happy to open a PR - but if anyone else wants to do get in there I'm happy for that too.

If I were to open a PR - are there some standards that each language page should mention / not mention?

Why list?

Hi, I would like to know why encode and decode using arrays.

Main use case for this spec seems to be hashing individual resource ids. E.g. you want /users/1Aq
In most case you will deal with one id. I'm wrong thinking this? (at least for I want to use this)

Using list make things cumbersome as I need to grab the first item in the list and add error handling to that. Specially in more strict languages like Haskell, Rust, etc.

If I want to encode or decoder several ids is not difficult to something like map. e.g.

// Elm
map encode [1,2,3]

// JS
[1,2,3].map(hashids.encode)

Maybe encoding/decoding all in one is substantially faster?
Thanks

Go -- bump up to 1.0

Hi Remi,

I updated the site (http://hashids.org/) + my versions. Here's what's different: https://github.com/ivanakimov/hashids.js#changelog.

I realize Go port is not at 0.3 yet, so it might be a few more changes to move to 1.0. Are you still up for the task? :)

Also, I got rid of www on the site (it was hosted on S3 before and it was required there when I started), but now it's on Github so it's cleaner without it. Redirects still work tho (www -> non).

If you have any issues with the site (#4) or any issues in general, just ping :]

P.S: I'm always watching Go and have it on my todo list to get into it, so kind of exciting to see the direction the language is going to.

Shared set of hashids tests

For each of the 40 implementations listed on the hashids website, has someone made sure they give the same results as each other? I'm sure several of them have been checked against others. But I wouldn't be surprised if at least one of them gives different results.

I feel like the website should have resources for implementers, and one of the resources should be a file containing a long list of unit tests. Possibly in JSON, possibly some other format that's easy to parse. Then implementers can include that file in their own test suites, and just write a (hopefully fairly simple) test runner for them. It would presumably have tests like:

  • Encoding this input list with (salt, min length, alphabet) gives this output string.
  • Decoding this (correctly encoded) string with (salt, min length, alphabet) gives this output list.
  • Decoding this (not a correctly encoded, but might look like one) string with (salt, min length, alphabet) fails, but doesn't crash unexpectedly.
  • Include edge cases. What's supposed to happen if you encode an empty list? Or one with negative numbers? Numbers that can't be represented as a float/double/64-bit int/whatever?[1] What if you use a too-short alphabet, or one with duplicate letters? Are the salt and/or alphabet allowed to include multi-byte characters? (If so, what if you have an alphabet with more than 255 letters, does that work fine?) Some of these might be left up to implementations to decide what fits in with their local ecosystem, but including them in the list of tests encourages implementers to think about them.

[1]: If using JSON, such numbers might need to be written as strings. Otherwise the parsing step might not preserve them correctly.

List of changes between 0.3 and 1.0

Is there a list of changes that need to be implemented in order to update our 0.3 libraries to 1.0? If not, then we should create one for use as a checklist. A shared suite of test cases would also be nice.

Iโ€™ll probably have time to look at updating the Ruby implementation later this week.

Negative integers not supported?

I tried to encode a negative integer with the Python version and get an empty string back.

I assume for the intended use case (database primary key ids) this doesn't matter but maybe you could mention it on the homepage somewhere - I didn't see any reference to only positive ints being supported.

Hashids organization maintanance

Hi all @hashids/owners,

Since Ivan apparently quit GitHub some time ago (the current account with the name ivanakimov is obviously not him) our "organization" future is at question.

I'd like to ask a few things:

  1. Should we keep the same group of maintainers? We're pretty occupied all of us and none of us has enough time to do all the stuff but at least we can keep the site intact.
  2. Who owns the domain hashids.org? If we're what's left as maintainers and none of us holds its rights, shouldn't we switch to another domain before it expires? (2020-05-11)
  3. "The bright future?" - any had any thoughts of 2.0?

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.