Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I suck at C

Name: Anonymous 2012-07-09 13:29

So I was trying to implement the SHA-1 hashing algorithm according to http://en.wikipedia.org/wiki/SHA-1 but it doesn't work. I get a hash but it's not what Wikipedia says it should be. What do?

http://pastebin.com/yqFVp9wG

Name: Anonymous 2012-07-09 13:44

Use a library. Trust me. I just tried implementing the scrypt KDF in PHP. Stuff is impossible. You just have to hope you code it perfectly.

Name: Anonymous 2012-07-09 13:52

That's not the point though I'm just doing it for fun.

Name: Anonymous 2012-07-09 14:01

>>3
Figure it out yourself, ``faggot''!

Name: Anonymous 2012-07-09 14:45

Read SICP.

Name: Anonymous 2012-07-09 15:36

Tip:

a ≡ b (mod c)

if

(a - b) is multiple of c, i.e., (a - b) % c == 0

Name: Anonymous 2012-07-09 15:49

Do you know the difference between rotation and shift?

Name: Anonymous 2012-07-09 16:23

7-san is right. Your message schedule is wrong. When the spec says << it means rotation, not shift. You have to move the bit sifted out into lsb position. Same with temp and c.

Name: Anonymous 2012-07-09 16:26

>>8
Use Java, its integer arithmetic handles this automatically for you

Name: Anonymous 2012-07-09 16:46

>>9
Or he could use C++: define a rotator class and overload the lsh and rsh operators with the RO(L|R) code or instructions. GC is shit.

Name: Anonymous 2012-07-09 17:00

>>9-10
Haha, >>1-san know you're kidding.

Name: Anonymous 2012-07-09 17:02

And don't forget that x86 is LE.

Name: Anonymous 2012-07-09 17:05

>>10
Good suggestion. OP could also use template specialization to generate precomputed hash outputs for common inputs (eg. "password") at compile time.

Name: Anonymous 2012-07-09 17:54


template<typename Data>
class rotator
{
private:
  Data data;
public:
  rotator(Data&& data)
    :data(std::move(data))
  {
  }

  rotator(const Data& data)
    :data(data)
  {
  }

  Data operator>>(const Data& a)
  {
    return (data >> a) |
      (data << CHAR_BIT*sizeof(Data)-1);
  }
  Data operator<<(const Data& a)
  {
    return (data << a) |
      (data >> CHAR_BIT*sizeof(Data)-1);
  }
  Data operator>>(const Data&& a)
  {
    return (data >> a) |
      (data << CHAR_BIT*sizeof(Data)-1);
  }
  Data operator<<(const Data&& a)
  {
    return (data << a) |
      (data >> CHAR_BIT*sizeof(Data)-1);
  }
};

Name: Anonymous 2012-07-09 18:23

Dicks all up in yo anus

Name: Anonymous 2012-07-10 7:03

#include <stdint.h>
n000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b

Don't change these.
Name: Email:
Entire Thread Thread List