ID:1622743
 
Keywords: 1, 224, 256, 384, 512, byond, crypto, cryptopp, hashing, sha

Library URL: Download cryptoBYOND


Available Functions:

SHA1();
SHA224();
SHA256();
SHA384();
SHA512();


How to use:

mob/verb/Test(T as text)
src<<SHA1(T);
src<<SHA224(T);
src<<SHA256(T);
src<<SHA384(T);
src<<SHA512(T);


Enjoy!


Please feel free to send me a generous donation below

Great library! I'll probably use this in the future over BYOND's built-in MD5 function.
Thanks much!
No problem. If you happen to come across any other hashing algorithm's that you would like to see in BYOND, I'll be more than happy to build it into this library.
This is exactly what we all needed. Thank you.
You're welcome :)
Provide source so that linux libs can be built please.
Ssj4justdale

Actually, after downloading you've not included your code files. It's just a .dme

the crap, o.o I dunno what happened but I'll fix it now.
I'll dual-boot my laptop and create a linux library, I'm busy at the moment attending other matters.
In response to Zecronious
Zecronious wrote:
Ssj4justdale

Actually, after downloading you've not included your code files. It's just a .dme

It was something with the compiler/packager not including the included files. I don't know what occurred but after fooling around for a bit, I got it to fix.

In response to Ssj4justdale
Seeming as you're implementing known cryptography hashing functions, is there any harm in open sourcing?
Compiling for specific architectures allows certain speed improvements to be made.
no harm whatsoever, just on my phone at the moment. What I meant to say is that i'll release the source after I build the linux library
In response to Ssj4justdale
Oh okay, cool!
In response to Ssj4justdale
Ssj4justdale wrote:
no harm whatsoever, just on my phone at the moment. What I meant to say is that i'll release the source after I build the linux library

How's this coming along?
It's on my Linux VPS, I'll upload when I get home
And now?
What's wrong with md5 for BYOND's purposes?
In response to Toadfish
Md5 has been proven time and time again to be completely insecure. It has hash collision issues (meaning sometimes there's two things that have the same hash) and has already been cracked. Meaning, even if you salt your hashes chances are someone can turn your md5 hash into plaintext anyway.

More info: https://crackstation.net/hashing-security.htm
Heres the source / works on linux when compiled and libs installed.

#include <string>
#include "cryptopp/sha.h"
#include "cryptopp/base64.h"
#include "cryptopp/hex.h"

#ifdef WIN32
extern "C" __declspec(dllexport) const char * SHA1(int argc, char ** argv);
extern "C" __declspec(dllexport) const char * SHA224(int argc, char ** argv);
extern "C" __declspec(dllexport) const char * SHA256(int argc, char ** argv);
extern "C" __declspec(dllexport) const char * SHA384(int argc, char ** argv);
extern "C" __declspec(dllexport) const char * SHA512(int argc, char ** argv);
#else
#include <cstring>
extern "C" const char * SHA1(int argc, char ** argv);
extern "C" const char * SHA224(int argc, char ** argv);
extern "C" const char * SHA256(int argc, char ** argv);
extern "C" const char * SHA384(int argc, char ** argv);
extern "C" const char * SHA512(int argc, char ** argv);
#endif

using namespace std;
string output;

const char * SHA1(int argc, char ** argv)
{
CryptoPP::SHA1 hash;
byte digest[ CryptoPP::SHA256::DIGESTSIZE ];
hash.CalculateDigest( digest, (const byte *)argv[0], strlen(argv[0]) );

CryptoPP::HexEncoder encoder;
output = "";
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();

return (const char *)output.c_str();
}


const char * SHA224(int argc, char ** argv)
{
CryptoPP::SHA224 hash;
byte digest[ CryptoPP::SHA224::DIGESTSIZE ];
hash.CalculateDigest( digest, (const byte *)argv[0], strlen(argv[0]) );

CryptoPP::HexEncoder encoder;
output = "";
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();

return (const char *)output.c_str();
}

const char * SHA256(int argc, char ** argv)
{
CryptoPP::SHA256 hash;
byte digest[ CryptoPP::SHA256::DIGESTSIZE ];
hash.CalculateDigest( digest, (const byte *)argv[0], strlen(argv[0]) );

CryptoPP::HexEncoder encoder;
output = "";
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();

return (const char *)output.c_str();
}


const char * SHA384(int argc, char ** argv)
{
CryptoPP::SHA384 hash;
byte digest[ CryptoPP::SHA384::DIGESTSIZE ];
hash.CalculateDigest( digest, (const byte *)argv[0], strlen(argv[0]) );

CryptoPP::HexEncoder encoder;
output = "";
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();

return (const char *)output.c_str();
}

const char * SHA512(int argc, char ** argv)
{
CryptoPP::SHA512 hash;
byte digest[ CryptoPP::SHA512::DIGESTSIZE ];
hash.CalculateDigest( digest, (const byte *)argv[0], strlen(argv[0]) );

CryptoPP::HexEncoder encoder;
output = "";
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();

return (const char *)output.c_str();
}
In response to Doohl
Doohl wrote:
Md5 has been proven time and time again to be completely insecure. It has hash collision issues (meaning sometimes there's two things that have the same hash) and has already been cracked. Meaning, even if you salt your hashes chances are someone can turn your md5 hash into plaintext anyway.

More info: https://crackstation.net/hashing-security.htm

So what? Nobody is going to do a cryptographic attack on a BYOND game.

Also, chosen prefix attacks on MD5 are still crappy so there is no reasonable way to use its vulnerabilities in a practical BYOND setting.
Page: 1 2