diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-07-17 20:32:57 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-07-17 20:32:57 +0200 |
commit | d3f7a7e363e2e8d1c8ce05108f3361b48ca954e6 (patch) | |
tree | eea11755d54d08b6626029366ef54267308ac136 /libpiano | |
parent | 7c96aa41979b1c1b0b4c582c8ac31b7ff779b737 (diff) | |
download | pianobar-windows-d3f7a7e363e2e8d1c8ce05108f3361b48ca954e6.tar.gz pianobar-windows-d3f7a7e363e2e8d1c8ce05108f3361b48ca954e6.tar.bz2 pianobar-windows-d3f7a7e363e2e8d1c8ce05108f3361b48ca954e6.zip |
piano: Little blowfish speed improvement
Diffstat (limited to 'libpiano')
-rw-r--r-- | libpiano/src/crypt.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libpiano/src/crypt.c b/libpiano/src/crypt.c index 82a7a49..9176408 100644 --- a/libpiano/src/crypt.c +++ b/libpiano/src/crypt.c @@ -23,6 +23,7 @@ THE SOFTWARE. #include <string.h> #include <stdio.h> #include <stdlib.h> +#include <byteswap.h> #include "crypt_key_output.h" #include "crypt_key_input.h" @@ -42,7 +43,6 @@ void PianoHexToInts (char *strHex, unsigned int **retInts, size_t *retIntsN) { /* FIXME: error handling: string too short, e.g. */ /* unsigned int = 4 bytes, 8 chars in hex */ for (i = 0; i < strlen (strHex); i += 8) { - memset (hexInt, 0, sizeof (hexInt)); memcpy (hexInt, strHex+i, sizeof (hexInt)-1); sscanf (hexInt, "%x", &arrInts[i/8]); } @@ -99,9 +99,13 @@ void PianoDecipherInts (unsigned int *cipherInts, size_t cipherIntsN, char *PianoIntsToString (unsigned int *arrInts, size_t arrIntsN) { char *strDecoded = calloc (arrIntsN * 4 + 1, sizeof (*strDecoded)); size_t i; + unsigned int *tmp; for (i = 0; i < arrIntsN; i++) { - snprintf (&strDecoded[i*4], arrIntsN * 4, "%c%c%c%c", ((arrInts[i] >> 24) & 0xff), ((arrInts[i] >> 16) & 0xff), ((arrInts[i] >> 8) & 0xff), ((arrInts[i] >> 0) & 0xff)); + /* map string to 4-byte int */ + tmp = (unsigned int *) &strDecoded[i*4]; + /* FIXME: big endian does not need to byteswap */ + *tmp = bswap_32 (arrInts[i]); } return strDecoded; } |