+// RotateLeft - Ultralight, Desfire
+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;
+}
+
+void lsl (uint8_t *data, size_t len) {
+ for (size_t n = 0; n < len - 1; n++) {
+ data[n] = (data[n] << 1) | (data[n+1] >> 7);
+ }
+ data[len - 1] <<= 1;
+}
+
+int32_t le24toh (uint8_t data[3]) {
+ return (data[2] << 16) | (data[1] << 8) | data[0];
+}
+
+//convert hex digit to integer
+uint8_t hex2int(char hexchar){
+ switch(hexchar){
+ case '0': return 0; break;
+ case '1': return 1; break;
+ case '2': return 2; break;
+ case '3': return 3; break;
+ case '4': return 4; break;
+ case '5': return 5; break;
+ case '6': return 6; break;
+ case '7': return 7; break;
+ case '8': return 8; break;
+ case '9': return 9; break;
+ case 'a':
+ case 'A': return 10; break;
+ case 'b':
+ case 'B': return 11; break;
+ case 'c':
+ case 'C': return 12; break;
+ case 'd':
+ case 'D': return 13; break;
+ case 'e':
+ case 'E': return 14; break;
+ case 'f':
+ case 'F': return 15; break;
+ default:
+ return 0;
+ }
+}
+
+void LEDsoff() {