Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. void decryptCounter(String zt){
  2.  
  3. int length = zt.length();
  4. byte pole [16];
  5.  
  6. int poc = 0;
  7. for(int i = 0; i < length;i=i+2){
  8. String pom = String(zt.charAt(i)) + String(zt.charAt(i+1));
  9. pole[poc] = int(hexToDec(pom));
  10. poc++;
  11. }
  12.  
  13. // // vypis
  14. // for(int i= 0; i < 16; i++){
  15. // Serial.println(pole[i]);
  16. // }
  17.  
  18. int blocks = 1;
  19. byte succ = aes.set_key (key, 128) ;
  20. succ = aes.decrypt (pole,decrypted) ;
  21.  
  22.  
  23. for (byte i = 0 ; i < blocks*N_BLOCK; i++)
  24. {
  25. byte val = decrypted[i];
  26. Serial.print(val>>4, HEX) ;
  27. Serial.print(val&15, HEX) ;
  28. // Serial.println(val);
  29.  
  30. }
  31. Serial.println () ;
  32.  
  33.  
  34. // char hexaCounter [2 * NUMBEROFBYTES + 1];
  35. //
  36. // char* myPtr = &hexaCounter[0]; //or just myPtr=charArr; but the former described it better.
  37. // for (byte i = 0; i < NUMBEROFBYTES; i++){
  38. // snprintf(myPtr,3,"%02x",decrypted[i]); //convert a byte to character string, and save 2 characters (+null) to charArr;
  39. // myPtr += 2; //increment the pointer by two characters in charArr so that next time the null from the previous go is overwritten.
  40. // }
  41. //
  42. //// Serial.println("Counter v HEX:");
  43. //// Serial.println(hexaCounter);
  44. //
  45. // long int retVal = hexToDec(String(hexaCounter));
  46. //
  47. // return retVal;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement