fork download
  1. #include <stdio.h>
  2.  
  3. static const unsigned char bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  4.  
  5. #define r64_get_1_byte( ucaf ) bin2ascii[ ( (ucaf)[0] >> 2 ) & 0x3f ]
  6. #define r64_get_2_byte( ucaf ) bin2ascii[ ( ( (ucaf)[0] << 4 ) & 0x30 ) | (( (ucaf)[1] >> 4 ) & 0x0f ) ]
  7.  
  8. int main(void) {
  9. char ucaf[10] = "kJ82958";
  10. char r1 = r64_get_1_byte( ucaf );
  11. char r2 = r64_get_2_byte( ucaf );
  12. printf("[%c]-[%c]\n");
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
[8]-[`]