Git Product home page Git Product logo

blowfish's Introduction

Hello, I am Avinal

Avinal WakaTime Activity

blowfish's People

Contributors

avinal avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blowfish's Issues

Bugs (and fixes)

Hello, I tried to use your library but couldn't get it to work.
I'm migrating some Rust code to C++ (yeah, sad), so I had a reference to compare.

I found a coulple of bugs:


data = (data << 8) | key[j];

Since key is a string, key[j] returns a signed char, which breaks my keys that are arrays of unsigned chars. So I changed:

data = (data << 8) | (unsigned char)key[j];

imho the key should not be a string


blowfish/src/blowfish.cc

Lines 254 to 260 in b6931e3

for (uint32_t i = 0; i < 4; ++i) {
for (uint32_t k = 0; k < 256; k += 2) {
encrypt(datal, datar);
Sboxes[i][j] = datal;
Sboxes[i][j + 1] = datar;
}
}

The array should be indexed by k instead of j.


Sboxes in being indexed incorrectly in F:

blowfish/src/blowfish.cc

Lines 269 to 277 in b6931e3

d = x & 0x00FF;
x >>= 8;
d = x & 0x00FF;
x >>= 8;
c = x & 0x00FF;
x >>= 8;
b = x & 0x00FF;
x >>= 8;
a = x & 0x00FF;

I changed it to (like the reference):

a = x >> 24;
b = (x >> 16) & 0xFF;
c = (x >> 8) & 0xFF;
d = x & 0xFF;

After those changes, I get the same results as in Rust!
Hope this helps someone who comes across this library

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.