Code Monkey home page Code Monkey logo

hashids's People

Contributors

addie9000 avatar dariodepaolis avatar malczak avatar willk37 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

hashids's Issues

iOS 11 requirement?

Why is iOS 11 the minimum deployment target? A lot of the apps have at least 10 as the deployment target or even lower, I don't see why updating it to Swift 4 made this a requirement.

Is this repo open for contributions?

If yes, how do we get started on contributing? A brief guide on how to setup this repo in Xcode so we can start coding and running tests would be great.

I tried cloning the repo but after that, there's no .xcodproj or .xcworkspace file to work with.

This library is unsafe and can crash on untrusted input

The following code will crash.

let hashOfMaxInt64 = "jvNx4BjM5KYjv" // untrusted input
let hashids = Hashids(salt: "this is my salt")
let values = hashids.decode64(hashOfMaxInt64) // ๐Ÿ’ฅ Crash

A simple hash of Int64.max will crash when attempting to decode because the double overflows the integer during decoding. Personally, I think the Double -> Int constructor should return an optional since it can fail as this ends up being a foot-gun in an otherwise safe language.

Because of how hashids work, it is impossible to know ahead of time if a given input is safe without first trying to decode it. If you run this library on a web server on untrusted input, you are at risk of a crash and should patch immediately.

I have opened a PR to address this, but considering this repo has been inactive, I don't expect it to be merged. I will leave my fork with the fix up for others to use.

Swift PM Support

Would be awesome if we could import this into our projects using Swift PM instead of cocoapods.

64bit int suppport

If I pass a int parameter larger than 2,147,483,647 in iphone 5 32bit device, it will crash for Int is 32bit.
Is this an issue?

Encoding incorrectly

let hashids = Hashids(salt: "icaslntrigresnisteet", minHashLength: 32, alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890");
hash = hashids.encode(1, 2, 8)

In Swift this yields:
n1EOZmo3bKArd9YcphPd742kWewMpvPR

In PHP (specifically with Laravel config)

'main' => [
    'salt'     => 'icaslntrigresnisteet',
    'length'   => 32,
    'alphabet' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890',
],

PHP yields:
n1EOZmo3bKArd9YCpHPd742kWewMpvPR

Notice that the C and H are lowercase in Swift but uppercase in PHP. This is really concerning... if I can't trust that the hashes are the same in Swift and PHP then I can't use this at all.

The 1, 2, 8 is just one example. I've tried many other numbers and the hash is always incorrect. It's always the two letters in position 16 and 18 that are lowercase and should be uppercase.

Swift 2.2 Support

There's 6 simple warnings for this library when used on Swift 2.2.

screen shot 2016-03-23 at 14 49 00

swift 3 problems in encoding

update doesn't conform to other hashids libraries ... try using generated hash from swift and decode with php or js library of hashids.

the encode does something else then the other version of hashids.org libraries.
the decode encodes the swift 3 version and the version of other libraries from hashids.org

Empty Salt not supported

Unlike the Java and JS equivalents this implementation doesn't appear to support empty salts:

let hashids = Hashids(salt:"", minHashLength: 20)
throws:
Fatal error: Remainder of division by zero

Swift 2 support

Looks like this is going to need some parts refactored for Swift 2 support.

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.