X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/20f9a2a1d54952ed15066c93490f0e8fb0d43b67..50193c1e3eb7f904bdc4be84618b1b045539597b:/client/util.c diff --git a/client/util.c b/client/util.c index fe89626f..d691eefc 100644 --- a/client/util.c +++ b/client/util.c @@ -30,3 +30,22 @@ char * sprint_hex(const uint8_t * data, const size_t len) { return buf; } + +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 num = 0; + while (len--) + { + num = (num << 8) | (*src); + src++; + } + return num; +}