Files
TCPlayerbotCore/dep/include/g3dlite/G3D/Crypto.h
T

47 lines
975 B
C++
Raw Normal View History

2009-02-09 08:16:34 -05:00
/**
2008-10-02 16:23:55 -05:00
@file Crypto.h
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
@maintainer Morgan McGuire, [email protected]
2009-02-09 08:16:34 -05:00
2008-10-02 16:23:55 -05:00
@created 2006-03-29
@edited 2006-04-06
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#ifndef G3D_CRYPTO_H
#define G3D_CRYPTO_H
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include "G3D/platform.h"
#include "G3D/g3dmath.h"
#include <string>
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
namespace G3D {
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** Cryptography and hashing helper functions */
class Crypto {
public:
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/**
Computes the CRC32 value of a byte array. CRC32 is designed to be a hash
function that produces different values for similar strings.
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
This implementation is compatible with PKZIP and GZIP.
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
Based on http://www.gamedev.net/reference/programming/features/crc32/
*/
static uint32 crc32(const void* bytes, size_t numBytes);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/**
Returns the nth prime less than 2000 in constant time. The first prime has index
0 and is the number 2.
*/
static int smallPrime(int n);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
/** Returns 1 + the largest value that can be passed to smallPrime. */
static int numSmallPrimes();
};
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#endif
2009-02-17 20:07:49 -06:00