X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/2de9622f0e8244c06acbce41fc5501ba7304e85b..1f1d974f02e20b4ce7996fa2159950fb2ea06750:/client/util.c diff --git a/client/util.c b/client/util.c index 99a26a40..4bbc992e 100644 --- a/client/util.c +++ b/client/util.c @@ -186,19 +186,16 @@ char *sprint_hex_ascii(const uint8_t *data, const size_t len) { return buf; } -void num_to_bytes(uint64_t n, size_t len, uint8_t* dest) -{ +void num_to_bytes(uint64_t n, size_t len, uint8_t* dest) { while (len--) { dest[len] = (uint8_t) n; n >>= 8; } } -uint64_t bytes_to_num(uint8_t* src, size_t len) -{ +uint64_t bytes_to_num(uint8_t* src, size_t len) { uint64_t num = 0; - while (len--) - { + while (len--) { num = (num << 8) | (*src); src++; } @@ -212,6 +209,7 @@ void num_to_bytebits(uint64_t n, size_t len, uint8_t *dest) { n >>= 1; } } + //least significant bit first void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest) { for(int i = 0 ; i < len ; ++i) { @@ -220,7 +218,6 @@ void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest) { } } - // aa,bb,cc,dd,ee,ff,gg,hh, ii,jj,kk,ll,mm,nn,oo,pp // to // hh,gg,ff,ee,dd,cc,bb,aa, pp,oo,nn,mm,ll,kk,jj,ii @@ -549,6 +546,7 @@ void rol(uint8_t *data, const size_t len){ } // Swap bit order on a uint32_t value. Can be limited by nrbits just use say 8bits reversal +// And clears the rest of the bits. uint32_t SwapBits(uint32_t value, int nrbits) { uint32_t newvalue = 0; for(int i = 0; i < nrbits; i++) {