Git Product home page Git Product logo

hashidsxx's People

Contributors

schoentoon avatar xinst 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hashidsxx's Issues

test suit failed

I am using a different suite library (not gtest), but the test.cpp file seems broken anyways.

C:\prj\hashidsxx>test
------  Encode Saltless
[FAIL]  Test 1 at test.cpp:11 (0 s)
        hash.encode({123}) == "Mj3"
        TEE == Mj3
        (unexpected)
------  Decode Saltless
[FAIL]  Test 2 at test.cpp:17 (0 s)
        output.size() == 1
        2 == 1
        (unexpected)
[FAIL]  Test 3 at test.cpp:18 (0 s)
        output[0] == 123
        0 == 123
        (unexpected)
------  Encode Salt
[FAIL]  Test 4 at test.cpp:23 (0 s)
        hash.encode({123}) == "0lb"
        6uu == 0lb
        (unexpected)
------  Decode Salt
[FAIL]  Test 5 at test.cpp:29 (0 s)
        output.size() == 1
        2 == 1
        (unexpected)
[FAIL]  Test 6 at test.cpp:30 (0 s)
        output[0] == 123
        0 == 123
        (unexpected)
------  Encode SaltMinLength
[ OK ]  Test 7 at test.cpp:36 (0 s)
[FAIL]  Test 8 at test.cpp:37 (0 s)
        output == "7P231QiYuXU53Y9"
        uw1FuZb4czdZtUz == 7P231QiYuXU53Y9
        (unexpected)
------  Decode SaltMinLength
[FAIL]  Test 9 at test.cpp:43 (0 s)
        output.size() == 4
        2 == 4
        (unexpected)
[FAIL]  Test 10 at test.cpp:44 (0.0010001 s)
        output[0] == 1
        30819229 == 1
        (unexpected)
[FAIL]  Test 11 at test.cpp:45 (0.0010001 s)
        output[1] == 2
        1259390737886 == 2
        (unexpected)
[FAIL]  Test 12 at test.cpp:46 (0 s)
        output[2] == 3
        30681189080760423 == 3
        (unexpected)
[FAIL]  Test 13 at test.cpp:47 (0 s)
        output[3] == 4
        9223372961785795680 == 4
        (unexpected)
[FAIL]  Test 14 at test.cpp:51 (0 s)
        output.size() == 1
        2 == 1
        (unexpected)
[FAIL]  Test 15 at test.cpp:52 (0 s)
        output[0] == 123
        0 == 123
        (unexpected)
------  Encode SaltMinLengthAlphabet
[ OK ]  Test 16 at test.cpp:59 (0 s)
[FAIL]  Test 17 at test.cpp:60 (0 s)
        output == "oavlpogkzrxrkpxd"
        slmwqitqnovtwtyk == oavlpogkzrxrkpxd
        (unexpected)
[ OK ]  Test 18 at test.cpp:62 (0 s)
------  Decode SaltMinLengthAlphabet
[FAIL]  Test 19 at test.cpp:69 (0 s)
        output.size() == 1
        2 == 1
        (unexpected)
[FAIL]  Test 20 at test.cpp:70 (0 s)
        output[0] == 123456789
        0 == 123456789
        (unexpected)
------  Encode Hex
[FAIL]  Test 21 at test.cpp:76 (0 s)
        output == "5RzW"
        7LPL == 5RzW
        (unexpected)
[FAIL]  Test 22 at test.cpp:78 (0 s)
        output == "8OlB1X6RjYuzPWW"
        HUTw1Z95FHPr1x0v == 8OlB1X6RjYuzPWW
        (unexpected)
------  Decode Hex
[FAIL]  Test 23 at test.cpp:84 (0 s)
        output == "abc"
         == abc
        (unexpected)
[FAIL]  Test 24 at test.cpp:86 (0 s)
        output == "f000000000000000f"
        2d6336c == f000000000000000f
        (unexpected)

[FAIL]  Failure! 21/24 tests failed :(
        Breakpoints: 0 (*)
        Total time: 0.0490049 seconds.

compiled failed in Visual Studio

When compile the demo src in vs, will get an error.

error C2511: 'hashidsxx::Hashids::Hashids(hashidsxx::Hashids &&)': overloaded member function not found in 'hashidsxx::Hashids'

the __cpluscplus is defined to 199711L , but in the hashids.cpp:71 need

`

if __cplusplus >= 201103

Hashids::Hashids(Hashids &&that)
: _salt(std::move(that._salt)), _alphabet(std::move(that._alphabet)),
_min_length(that._min_length), _separators(std::move(that._separators)),
_guards(std::move(that._guards)) {}

endif

`

same as the header file.

How to compress UUID string?

I tried this but it generates a way too long hash v25TOEtz2CqquQ5c4ri7KtDFxQfNxfpoSp9TEKcMRiGTwX

using namespace boost::uuids;

std::string guidString {"3eb3ad5a-a9ae-4216-ab74-d96ea2fd0c96"};
uuid guidBytes {boost::lexical_cast<uuid>(guidString)};

hashidsxx::Hashids hasher {};
std::string hash {hasher.encode(guidBytes.begin(), guidBytes.end())};

std::stringstream ss;
for (uint8_t byte : guidBytes) {
    ss << std::to_string(byte) << ", ";
}

return session->close(
    guidString + "\n" + 
    std::to_string(guidBytes.size()) + "\n" + 
    ss.str() + "\n" + 
    hash
);

This is the equivalent in JS https://codepen.io/anon/pen/KQKKrK

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.