diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-08-09 13:05:54 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-08-09 13:05:54 +0000 |
commit | 16675230f6fff2b30b48b83e395e273919b5515f (patch) | |
tree | b55bc1f455b99e7dd9635cd06c9aae9c93be1ac2 /src/common/strlib.c | |
parent | c5c74a00ce7bbc152f20066c22952770535dd7f5 (diff) | |
download | hercules-16675230f6fff2b30b48b83e395e273919b5515f.tar.gz hercules-16675230f6fff2b30b48b83e395e273919b5515f.tar.bz2 hercules-16675230f6fff2b30b48b83e395e273919b5515f.tar.xz hercules-16675230f6fff2b30b48b83e395e273919b5515f.zip |
Fixed login printing raw passwdenc passwords to console (bugreport:826).
Added strlib function bin2hex().
Cleaned up the md5calc interface a bit.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13055 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/strlib.c')
-rw-r--r-- | src/common/strlib.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c index 88de59cb9..93b69ab54 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -363,6 +363,28 @@ int strline(const char* str, size_t pos) return line; } +/// Produces the hexadecimal representation of the given input. +/// The output buffer must be at least count*2+1 in size. +/// Returns true on success, false on failure. +/// +/// @param output Output string +/// @param input Binary input buffer +/// @param count Number of bytes to convert +bool bin2hex(char* output, unsigned char* input, size_t count) +{ + char toHex[] = "0123456789abcdef"; + size_t i; + + for( i = 0; i < count; ++i ) + { + *output++ = toHex[(*input & 0xF0) >> 4]; + *output++ = toHex[(*input & 0x0F) >> 0]; + ++input; + } + *output = '\0'; + return true; +} + ///////////////////////////////////////////////////////////////////// |