Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo off
- title Cifrado Fibonacci [CharSecurity]
- ::PoC del Cifrado de Fibonacci de CharSecurity
- ::Coded by SmartGenius [27/01/2012]
- ::http://smart.code-makers.net
- Setlocal Enabledelayedexpansion
- Call :Init
- :Main
- Cls&Set "String="&Set "Opc="&Echo.
- Set /p "Opc=[C] Cifrar - [D] Descifrar > "
- If Not Defined Opc Goto :Main
- If /i "%Opc%"=="C" (Set "V=+") Else (
- If /i "%Opc%"=="D" (Set "V=-") Else (Goto :Main))
- Set /p "String=String >> "
- If Not Defined String Goto :Main
- Call :StrLen "%String%" StrLen
- Set /a "Lim=%StrLen%-1"
- For /l %%L in (0,1,%StrLen%) do (Call :Cipher "!String:~%%L,1!" "%%L" "Result")
- Echo.
- Echo. String= %String%
- Echo. Result= %Result%
- Echo.
- Pause
- Exit /b 0
- :Cipher
- Set "chr=%~1"
- For /l %%l in (0 1 62) do (
- If "!chr!" equ " " (
- Set "%~3=!%~3! "
- Goto :Eof)
- If "!chr!" equ "!AlfaNum:~%%l,1!" (
- Set /a "X=(%%l!V!(!Fib[%~2]!%%62))"
- Call Set "%~3=!%~3!%%AlfaNum:~!X!,1%%"
- ))
- Goto :Eof
- :StrLen
- SetLocal
- For /f %%_ in ('Cmd /U /C Echo.%~1^|More') Do Set/A "Len+=1"
- (EndLocal&Set "%~2=%Len%"&Exit/B 0;)
- :Init
- Set "F=0"
- Set "AlfaNum=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- 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"
- For %%F in (%Fib%) do (
- Set "Fib[!F!]=%%F"
- Set /a "F+=1")
- Goto :Eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement