Показать сообщение отдельно

  #2  
Старый 28.04.2025, 11:06
chromiusj
Флудер
Регистрация: 10.08.2021
Сообщений: 6,010
С нами: 2505538

Репутация: 133


По умолчанию

а зачем это дело еще и компилировать то?

Python:





Код:
import
base64
import
hashlib
def
encode_base64
(
text
)
:
return
base64
.
b64encode
(
text
.
encode
(
'utf-8'
)
)
.
decode
(
'utf-8'
)
def
decode_base64
(
encoded_text
)
:
return
base64
.
b64decode
(
encoded_text
)
.
decode
(
'utf-8'
)
def
encode_utf8
(
text
)
:
return
text
.
encode
(
'utf-8'
)
def
decode_utf8
(
byte_text
)
:
return
byte_text
.
decode
(
'utf-8'
)
def
encode_hex
(
text
)
:
return
text
.
encode
(
'utf-8'
)
.
hex
(
)
def
decode_hex
(
encoded_text
)
:
return
bytes
.
fromhex
(
encoded_text
)
.
decode
(
'utf-8'
)
def
hash_md5
(
text
)
:
return
hashlib
.
md5
(
text
.
encode
(
'utf-8'
)
)
.
hexdigest
(
)
def
hash_sha256
(
text
)
:
return
hashlib
.
sha256
(
text
.
encode
(
'utf-8'
)
)
.
hexdigest
(
)
def
caesar_cipher
(
text
,
shift
)
:
result
=
''
for
char
in
text
:
if
char
.
isalpha
(
)
:
shifted
=
chr
(
(
ord
(
char
.
lower
(
)
)
-
97
+
shift
)
%
26
+
97
)
if
char
.
isupper
(
)
:
shifted
=
shifted
.
upper
(
)
result
+=
shifted
else
:
# inserted
result
+=
char
return
result
def
xor_cipher
(
text
,
key
)
:
return
''
.
join
(
(
chr
(
ord
(
c
)
^
key
)
for
c
in
text
)
)
def
rot13
(
text
)
:
return
text
.
translate
(
str
.
maketrans
(
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
,
'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'
)
)
MORSE_CODE_DICT
=
{
'A'
:
'.-'
,
'B'
:
'-...'
,
'C'
:
'-.-.'
,
'D'
:
'-..'
,
'E'
:
'.'
,
'F'
:
'..-.'
,
'G'
:
'--.'
,
'H'
:
'....'
,
'K'
:
'-.-'
,
'L'
:
'.-..'
,
'M'
:
'--'
,
'N'
:
'-.'
,
'O'
:
'O'
,
'Q'
:
'--.-'
,
'R'
:
'.-.'
,
'S'
:
'...'
,
'T'
:
'-'
,
'U'
:
'..-'
,
'V'
:
'...-'
,
'W'
:
'.--'
,
'X'
:
'-..-'
,
'Y'
:
'-.--'
,
'-.--'
:
'Z'
,
'-.--'
:
'--..'
,
'1'
:
'1'
,
'
def
encode_morse
(
text
)
:
text
=
text
.
upper
(
)
morse_code
=
[
]
for
char
in
text
:
if
char
!=
' '
:
morse_code
.
append
(
MORSE_CODE_DICT
.
get
(
char
,
''
)
)
else
:
# inserted
morse_code
.
append
(
' '
)
return
' '
.
join
(
morse_code
)
def
decode_morse
(
morse_text
)
:
morse_code_dict_reversed
=
{
value
:
key
for
key
,
value
in
MORSE_CODE_DICT
.
items
(
)
}
words
=
morse_text
.
split
(
'   '
)
decoded_message
=
''
for
word
in
words
:
letters
=
word
.
split
(
)
for
letter
in
letters
:
decoded_message
+=
morse_code_dict_reversed
.
get
(
letter
,
''
)
decoded_message
+=
' '
return
decoded_message
.
strip
(
)
def
xor_cipher_simple
(
text
,
key
)
:
return
''
.
join
(
(
chr
(
ord
(
c
)
^
key
)
for
c
in
text
)
)
print
(
'Выберите метод шифрования:'
)
print
(
'1. Base64'
)
print
(
'2. UTF-8 (Преобразование в байты)'
)
print
(
'3. Hex'
)
print
(
'4. MD5 (Хэширование)'
)
print
(
'5. SHA-256 (Хэширование)'
)
print
(
'6. Caesar Cipher (Цезарь сдвиг)'
)
print
(
'7. XOR Cipher'
)
print
(
'8. ROT13'
)
print
(
'9. Азбука Морзе'
)
print
(
'10. Простое XOR шифрование'
)
action
=
input
(
'Введите номер действия (1-10): '
)
if
action
==
'1'
:
text
=
input
(
'Введите текст для кодирования: '
)
encoded
=
encode_base64
(
text
)
print
(
f'Закодированный текст (Base64):{encoded}'
)
 
Ответить с цитированием