Giter Site home page Giter Site logo

andreystepanov / hashids.sql Goto Github PK

View Code? Open in Web Editor NEW
47.0 2.0 10.0 8 KB

PL/pgSQL implementation of hashids library

Home Page: https://hashids.org/

License: MIT License

PLpgSQL 100.00%
hashids plpgsql postgresql rds id shortid aws aws-rds aws-rds-postgres sql

hashids.sql's People

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

Watchers

 avatar  avatar

hashids.sql's Issues

Incorrect encoding for 0 value.

The implementation of the hashids.to_alphabet function leads to different encodings for the value 0 compared to implementations in other languages. Specifically, if current_number begins as 0 the function is essentially skipped.

while current_number > 0 loop

Python:
https://github.com/davidaurelio/hashids-python/blob/09f879a1967836f1e399c12b745c24291e3e73ad/hashids.py#L43

Ruby:
https://github.com/peterhellberg/hashids.rb/blob/b729fe514e492e18d9f69473b53eb59a3b5aee4b/lib/hashids.rb#L163

Custom alphabet produces different results than other libraries

Thank you for getting this off the ground! In doing some playing around I noticed that I got different results when I used a custom alphabet using your library than through the Javascript or Ruby versions.

I used this codepen from Ivan Akimov to test the JS version:
https://codepen.io/ivanakimov/pen/bNmExm

ID: 1 / salt: 'salt' / no custom alphabet - OK
Javascript: XG
Ruby: XG
PL/SQL: XG

ID: 1 / min_length: 6 / salt: 'salt' / no custom alphabet - OK
Javascript: xkXG8Z
Ruby: xkXG8Z
PL/SQL: xkXG8Z

ID: 1 / min_length: 6 / salt: 'salt' / alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - ERROR
Javascript: MEPWMP
Ruby: MEPWMP
PL/SQL: JPRAPM

I wish I could offer more assistance.

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.