]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/util.c
add bitswap option for lf em 4x05write
[proxmark3-svn] / client / util.c
index 374ae397a3415d9b8c916cc3573357c36193e89c..60054b9410d9c310217eca720f460f45bc87b1f1 100644 (file)
@@ -8,6 +8,7 @@
 // utilities
 //-----------------------------------------------------------------------------
 
+#include <ctype.h>
 #include "util.h"
 #define MAX_BIN_BREAK_LENGTH   (3072+384+1)
 
@@ -244,6 +245,15 @@ void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest) {
        }
 }
 
+// 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++) {
+               newvalue ^= ((value >> i) & 1) << (nrbits - 1 - i);
+       }
+       return newvalue;
+}
 
 // aa,bb,cc,dd,ee,ff,gg,hh, ii,jj,kk,ll,mm,nn,oo,pp
 // to
@@ -581,3 +591,12 @@ void rol(uint8_t *data, const size_t len){
     }
     data[len-1] = first;
 }
+
+
+// Replace unprintable characters with a dot in char buffer
+void clean_ascii(unsigned char *buf, size_t len) {
+  for (size_t i = 0; i < len; i++) {
+    if (!isprint(buf[i]))
+      buf[i] = '.';
+  }
+}
Impressum, Datenschutz