Advertisement
DePhoegon

Step 1 - Decimal to binary

Jan 4th, 2019
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.20 KB | None | 0 0
  1. :: Incomplete project idea. Setup to allow unconventional methods of passwording tamper detection w/o encryption.   Meant to be light & lean when it use.
  2. :: conceptually transferable to other programming languages & somewhat universal.
  3. @echo off
  4. set VAL=A
  5. set NUM=%1
  6. set MAT=0
  7. set FMAT=0
  8. set DGC=0
  9. set MLC=2
  10. set CTL=0
  11. set HLD=2
  12. set CHK=0
  13. set CNT=0
  14. If %NUM% GTR 1 set CHK=1
  15. if %NUM% EQU 1 (set VAL=%VAL%1&& goto Derp)
  16. if %NUM% EQU 0 (set VAL=%VAL%0&& goto Derp)
  17. if %NUM% LSS 0 (goto OOF&& echo Invalid input)
  18. :Big
  19. set /a CNT=%CNT%+1
  20. if %NUM% GTR %HLD% (set /a HLD=%HLD%*2&& goto Big)
  21. if %NUM% EQU %HLD% set MAT=1
  22. if %NUM% LSS %HLD% set /a HLD=%HLD%/2
  23. if %MAT% EQU 1 goto MLoop
  24. :Loop
  25. set VAL=%VAL%1
  26. set /a NUM=%NUM%-%HLD%
  27. :Zed
  28. set /a HLD=%HLD%/2
  29. if %HLD% GTR %NUM% (set VAL=%VAL%0&& goto Zed)
  30. if %NUM% EQU 1 (set VAL=%VAL%1&& goto Derp)
  31. if %NUM% EQU 0 (set VAL=%VAL%0&& goto Derp)
  32. if %HLD% LSS %NUM% goto Loop
  33. :MLoop
  34. set /a DGC=%DGC%+1
  35. if %MLC% LSS %NUM% (set /a MLC=%MLC%*2&& goto MLoop)
  36. :DLoop
  37. if %FMAT% EQU 0 (set VAL=%VAL%1) else (set VAL=%VAL%0)
  38. set /a MLC=%MLC%/2
  39. set FMAT=1
  40. if %MLC% EQU 1 (set VAL=%VAL%0&& goto Derp)else (goto DLoop)
  41. :Derp
  42. set VAL=%VAL:~1%
  43. echo %VAL%
  44. :OOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement