fork download
  1. #include <iostream>
  2.  
  3. typedef unsigned char byte;
  4.  
  5. byte calc_iv(byte buffer[])
  6. {
  7. int iv = 0;
  8. size_t len = sizeof(buffer); // get buffer size
  9. for(int i = 0; i < len; i++) {
  10. byte I = buffer[i];
  11. iv += I;
  12. iv *= I + 1;
  13. }
  14. return iv / (len);
  15. }
  16.  
  17. int main(){
  18. byte buf[] = {41, 32, 16};
  19. byte iv = calc_iv(buf);
  20.  
  21. std::cout<<(int)iv<<std::endl;
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
208