Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. private string BinToHex(string vstup)
  2. {
  3. string[] bin = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111",
  4. "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
  5.  
  6. string[] hex = {"0", "1", "2", "3", "4", "5", "6", "7",
  7. "8", "9", "A", "B", "C", "D", "E", "F"};
  8.  
  9. string vystup = "";
  10.  
  11. while(vstup.Length % 4 != 0)
  12. {
  13. vstup = "0" + vstup;
  14. }
  15.  
  16. for(int i = 0; i < vstup.Length / 4; i++)
  17. {
  18. vystup += hex[Array.IndexOf(bin, vstup.Substring(i * 4, 4))];
  19. }
  20.  
  21. return vystup;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement