Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsort is not equivalent to the original sorting algorithm #1

Closed
clowwindy opened this issue Dec 27, 2012 · 1 comment
Closed

qsort is not equivalent to the original sorting algorithm #1

clowwindy opened this issue Dec 27, 2012 · 1 comment

Comments

@clowwindy
Copy link
Contributor

I find a bug when I try to port your code to iOS. qsort is not equivalent to the original code. It's not a stable sorting algorithm, so it will generate a different cipher with the one generated by Python or node.js server.

You can find the right implementation with bubble sort here:

https://github.com/clowwindy/shadowsocks-libev/blob/master/encrypt.c

If you want to speed up the calculation, use merge sort, which is a stable sorting algorithm with n*log(n) complexity.

@madeye
Copy link
Contributor

madeye commented Dec 27, 2012

Got it, I will try to implement a merge sort instead.

By the way, current android client is a porting of shadowsocks-go with cross compiled binary using cgo. I am still working on the libev implementation and the related codes should be buggy.

Thanks,
Max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants