X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/d04b71c168abf2655583c7817127e1f68efa328f..60bb5ef73b299f4abdbf657b34477dfb1f94e35d:/client/util.c diff --git a/client/util.c b/client/util.c index 9d4c83ee..fcda9bde 100644 --- a/client/util.c +++ b/client/util.c @@ -503,10 +503,18 @@ uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits) { // RotateLeft - Ultralight, Desfire, works on byte level // 00-01-02 >> 01-02-00 -void rol(uint8_t *data, const size_t len){ +void rol(uint8_t *data, const size_t len){ uint8_t first = data[0]; for (size_t i = 0; i < len-1; i++) { data[i] = data[i+1]; } data[len-1] = first; +} + +uint32_t SwapBits(uint32_t value, int nrbits) { + uint32_t newvalue = 0; + for(int i = 0; i < nrbits; i++) { + newvalue ^= ((value >> i) & 1) << (nrbits - 1 - i); + } + return newvalue; } \ No newline at end of file