Reverse the order of a hex string
Your issue seems to be byte order (big endian) and not bit order. The simplest solution to byte order swap is to use the builtin functions provided by the compiler (AVR GCC).

unsigned long cardCode;
...
Serial.print(__builtin_bswap32(cardCode), HEX);


There are two compiler builtin functions for byte order swap. One for 16-bit data and one for 32-bit data. 

uint16_t __builtin_bswap16(uint16_t);
uint32_t __builtin_bswap32(uint32_t);


AVR MCUs are little endian (least significant byte first in memory). There are many devices that use big endian (most significant byte first). This is also known as network order. There are a set of functions/macros to help write portable code, especially device drivers.

#include &lt;arpa/inet.h&gt;
uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);


These are used to map data from host to network byte order and reverse. They are defined as byte swap functions for hosts with little endian byte order. Unfortunately they are not available in the GCC AVR library but easy to define.

#define htonl(x) __builtin_bswap32((uint32_t) (x))
...


Cheers!