一个关于摩斯密码解密与加密的库 / A library about encoding and decoding Morse code.

Overview

Morsecoder

By Lemonix

Python 图标 Build 图标 License 图标


介绍

一个关于摩斯密码解密与加密的库

Warning: 本项目基于 Python3.6+ 开发,低版本会出现Bug

v0.51更新内容

  • 细节优化,修复已知Bug
  • 性能优化,去除冗余代码
  • 添加getArgs, setArgs等函数
  • morse_en和morse_de函数分别改为getEncode和getDecode
  • 美化__str__和__repr__魔术方法的返回值,print出来的结果更明了
  • 完善文档

v0.52预告

  • 使用内部调用函数,速度更快
  • 更强大的setArgs方法
  • __slots__魔术变量的使用
  • toString和toList方法让生成结果更方便

使用教程 (以下[ ]内的内容代表可选参数)

  • 实例化与设置
morse = Morsecoder( [文本, 分隔符] )
  • 加密与解密
# 加密
for i in morse.getEncode():
    print(i, end='')
print()

# 解密
for i in morse.getDecode():
    print(i, end='')
print()
  • 查看文本与分隔符
# 文本
morse.getArgs()['text']

# 分隔符
morse.getArgs()['sep']
  • 修改或添加摩斯密码对照表的内容
# key是键,value是值
Morsecoder.modify(key, value)
  • 初始化后设置参数
morse.setArgs(文本, 分隔符)
  • 查看对照表内容
# enList为编码表,deList为解码表
Morsecoder.getList(对照表类型)

使用实例 (此导入方式仅针对同文件夹导入)

用分隔符"/"加密字符串"你好世界"

from morsecoder import Morsecoder

morse1 = Morsecoder(text='你好世界', sep='/')
for i in morse1.getEncode():
    print(i, end="")
print() # 输出空行

输出:

-..----.--...../-.--..-.-----.-/-..---....-.--./---.-.-.-..--../

解密摩斯密码".-.././--/---/-./../-..-/"

from morsecoder import Morsecoder

morse1 = Morsecoder(text='.-.././--/---/-./../-..-/', sep='/')
for i in morse1.getDecode():
    print(i, end="")
print() # 输出空行

输出:

LEMONIX

向摩斯密码对照表中添加"①",对应摩斯密码为".-.-.-"

from morsecoder import Morsecoder

Morsecoder.modify('①', '.-.-.-')

部分功能测试

from morsecoder import Morsecoder

# 编码演示
myCode = Morsecoder(text='Hello World', sep='/')
for values in myCode.getEncode():
    print(values, end='')
print()
    
# 译码演示
myCode.setArgs(text='...././.-../.-../---/ /.--/---/.-./.-../-../', 
            sep=myCode.getArgs()['sep']
            )
for values in myCode.getDecode():
    print(values, end='')
print()

# __str__
print(myCode)
    
# Doc
print(help(Morsecoder))

输出:

...././.-../.-../---/ /.--/---/.-./.-../-../
HELLO WORLD

Instance -> 'Morsecoder'
Text(11) -> '...././.-../.-../---/ .--/---/.-./.-../-..'
Sep(1) -> '/'
        
Help on class Morsecoder in module __main__:

class Morsecoder(builtins.object)
 |  Morsecoder(text='', sep='')
 |  
 |  基于Python3.6+的摩斯密码库,
 |  支持编码, 译码, 自定义密码
 |  
 |  Methods defined here:
 |  
 |  __init__(self, text='', sep='')
 |      初始化参数,
 |      设置文本, 分隔符以及自动分析空格,
 |      如果当前文本含有不在对照表不包含的字符时,
 |      会通过Unicode进行编码
 |  
 |  __repr__ = __str__(self)
 |  
 |  __str__(self)
 |      Return str(self).
 |  
 |  getArgs(self)
 |      获取当前实例的参数
 |  
 |  getDecode(self)
 |      获取当前实例的译码
 |  
 |  getEncode(self)
 |      获取当前实例的编码
 |  
 |  getList(listType)
 |      获取编码表或译码表
 |  
 |  modify(key, value)
 |      修改编码表或译码表
 |  
 |  setArgs(self, text, sep)
 |      设置当前实例的参数
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  AUTHOR = 'Lemonix'
 |  
 |  VERSION = 0.51

None

参与贡献

Lemonix(开发与测试), Sherlockcxk(优化与测试)

Lemonix-Gitee

Lemonix-Github

Sherlockcxk-Gitee

Sherlockcxk-Github

你知道吗:

Morsecoder第一个版本:RtMorsecoder于2021/1/11 17:19发布

Morsecoder的灵感来源于本项目的共同开发者Sherlockcxk的C#项目Morsecoder

You might also like...
A lightweight encryption library in python.

XCrypt About This was initially a project to prove that I could make a strong encryption but I decided to publish it so that the internet peoples coul

A simple python program to sign text using either the RSA or ISRSAC algorithm with GUI built using tkinter library.
A simple python program to sign text using either the RSA or ISRSAC algorithm with GUI built using tkinter library.

Digital Signatures using ISRSAC Algorithm A simple python program to sign text using either the RSA or ISRSAC algorithm with GUI built using tkinter l

Salted Crypto Python library

Salted Crypto Python library. Allows to encrypt and decrypt files and directories using popular cryptographic algorithms with salty key(s).

Bsvlib - Bitcoin SV (BSV) Python Library

bsvlib A Bitcoin SV (BSV) Python Library that is extremely simple to use but mor

 C0mptCrypt - An object-oriented, minamalistic, simple encryption library in Python
C0mptCrypt - An object-oriented, minamalistic, simple encryption library in Python

C0mptCrypt allows you to encrypt strings of text. It can only be decrypted using C0mptCrypt and not by random online tools. You can use this for a variety of things from creating passwords, to encrypting HWIDs.

obj-encrypt is an encryption library based on the AES-256 algorithm.

obj-encrypt is an encryption library based on the AES-256 algorithm. It uses Python objects as the basic unit, which can convert objects into binary ciphertext and support decryption. Objects encrypted with obj-encrypt support TCP communication, database storage, and more.

A tool that can encrypt python2 or python3 code with the given password and can reuse with that password
A tool that can encrypt python2 or python3 code with the given password and can reuse with that password

A tool that can encrypt python2 or python3 code with the given password and can reuse with that password

PyCrypter , A Tool To Encrypt/Decrypt Text/Code With Ease And Safe Using Password !

PyCrypter PyCrypter , A Tool To Encrypt/Decrypt Text/Code With Ease And Safe Using Password ! Requirements pyfiglet And colorama Usage First Clone The

A short code in python, Enchpyter, is able to encrypt and decrypt words as you determine, of course

Enchpyter Enchpyter is a program do encrypt and decrypt any word you want (just letters). You enter how many letters jumps and write the word, so, the

Mysterium the first tool which permits you to retrieve the most part of a Python code even the .py or .pyc was extracted from an executable file, even it is encrypted with every existing encryptage. Mysterium don't make any difference between encrypted and non encrypted files, it can retrieve code from Pyarmor or .pyc files.

Mysterium the first tool which permits you to retrieve the most part of a Python code even the .py or .pyc was extracted from an executable file, even it is encrypted with every existing encryptage. Mysterium don't make any difference between encrypted and non encrypted files, it can retrieve code from Pyarmor or .pyc files.

Venax 116 Dec 21, 2022
Encrypt your code without a worry. Stark utilizes the base64, hashlib and Crypto lib to encrypt your code which cannot be decrypted with any online tools.

Stark Encrypt your code without a worry. Stark utilizes the base64, hashlib and Crypto lib to encrypt your code which cannot be decrypted with any onl

cliphd 3 Sep 10, 2021
A Python library to wrap age and minisign to provide key management, encryption/decryption and signing/verification functionality.

A Python library to wrap age and minisign to provide key management, encryption/decryption and signing/verification functionality.

Vinay Sajip 3 Feb 1, 2022
Python binding to the Networking and Cryptography (NaCl) library

PyNaCl: Python binding to the libsodium library PyNaCl is a Python binding to libsodium, which is a fork of the Networking and Cryptography library. T

Python Cryptographic Authority 941 Jan 4, 2023
Python ASN.1 library with a focus on performance and a pythonic API

asn1crypto A fast, pure Python library for parsing and serializing ASN.1 structures. Features Why Another Python ASN.1 Library? Related Crypto Librari

Will Bond 282 Dec 11, 2022
Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.

Tink A multi-language, cross-platform library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse. Ubuntu

Google 12.9k Jan 5, 2023
Cryptocurrency application that displays instant cryptocurrency prices and reads prices with the Google Text-to-Speech library.

?? Cryptocurrency Price App ?? ◽ Cryptocurrency application that displays instant cryptocurrency prices and reads prices with the Google Text-to-Speec

Furkan Mert 2 Nov 8, 2021
Modeval (or Modular Eval) is a modular and secure string evaluation library that can be used to create custom parsers or interpreters.

modeval Modeval (or Modular Eval) is a modular and secure string evaluation library that can be used to create custom parsers or interpreters. Basic U

null 2 Jan 1, 2022
The leading native Python SSHv2 protocol library.

Paramiko Paramiko: Python SSH module Copyright: Copyright (c) 2009 Robey Pointer <[email protected]> Copyright: Copyright (c) 2020 Jeff Forcier <

null 8.1k Jan 8, 2023
A self-contained cryptographic library for Python

PyCryptodome PyCryptodome is a self-contained Python package of low-level cryptographic primitives. It supports Python 2.7, Python 3.4 and newer, and

Helder Eijs 2.2k Jan 8, 2023