Advertisement
SmartGenius

Cifrado de Fibonacci de CharSecurity

May 27th, 2012
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. @Echo off
  2. title Cifrado Fibonacci [CharSecurity]
  3.  
  4. ::PoC del Cifrado de Fibonacci de CharSecurity
  5. ::Coded by SmartGenius [27/01/2012]
  6. ::http://smart.code-makers.net
  7.  
  8. Setlocal Enabledelayedexpansion
  9.  
  10. Call :Init
  11.  
  12. :Main
  13. Cls&Set "String="&Set "Opc="&Echo.
  14. Set /p "Opc=[C] Cifrar - [D] Descifrar > "
  15. If Not Defined Opc Goto :Main
  16. If /i "%Opc%"=="C" (Set "V=+") Else (
  17. If /i "%Opc%"=="D" (Set "V=-") Else (Goto :Main))
  18. Set /p "String=String >> "
  19. If Not Defined String Goto :Main
  20. Call :StrLen "%String%" StrLen
  21. Set /a "Lim=%StrLen%-1"
  22. For /l %%L in (0,1,%StrLen%) do (Call :Cipher "!String:~%%L,1!" "%%L" "Result")
  23. Echo.
  24. Echo. String= %String%
  25. Echo. Result= %Result%
  26. Echo.
  27. Pause
  28. Exit /b 0
  29.  
  30. :Cipher
  31. Set "chr=%~1"
  32. For /l %%l in (0 1 62) do (
  33. If "!chr!" equ " " (
  34. Set "%~3=!%~3! "
  35. Goto :Eof)
  36. If "!chr!" equ "!AlfaNum:~%%l,1!" (
  37. Set /a "X=(%%l!V!(!Fib[%~2]!%%62))"
  38. Call Set "%~3=!%~3!%%AlfaNum:~!X!,1%%"
  39. ))
  40. Goto :Eof
  41.  
  42. :StrLen
  43. SetLocal
  44. For /f %%_ in ('Cmd /U /C Echo.%~1^|More') Do Set/A "Len+=1"
  45. (EndLocal&Set "%~2=%Len%"&Exit/B 0;)
  46.  
  47. :Init
  48. Set "F=0"
  49. Set "AlfaNum=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  50. Set "Fib=1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393"
  51. For %%F in (%Fib%) do (
  52. Set "Fib[!F!]=%%F"
  53. Set /a "F+=1")
  54. Goto :Eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement