一个关于摩斯密码解密与加密的库 / 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

Simple bitcoin ticker for the Pimorono Inky pHAT Red.

bitcoin-ticker Simple bitcoin ticker for the Pimorono Inky pHAT Red. Equipment Raspberry Pi Zero W v1.1 or Pi 2 model b v1.1 Pimorono Inky pHAT Red (S

2 Mar 15, 2022
Two modules that display rates of fiat currencies and cryptocurrencies

currency-rates-polybar Two modules that display rates of fiat currencies and cryptocurrencies Setup Clone the repository somewhere Move (or create sym

Peskov Sergey 2 Apr 03, 2022
Stor is a community-driven green cryptocurrency based on a proof of space and time consensus algorithm.

Stor Blockchain Stor is a community-driven green cryptocurrency based on a proof of space and time consensus algorithm. For more information, see our

Stor Network 15 May 18, 2022
Python implementation of EIP 1577 content hash

ContentHash for Python Python implementation of EIP 1577 content hash. Description This is a simple package made for encoding and decoding content has

Filip Š 11 Jul 19, 2022
Python Encryption Name Game

Python 3.9.7 Encryption Name Game Encrypt a name with numbers using a Caesar cipher! You can choose different numbers to encrypt your name from 1 to o

Armand Brunelle 3 Dec 24, 2021
Image Encryption/Decryption based on Rubik Cube 's principle and AES

Image Encryption/Decryption based on Rubik Cube 's principle and AES Our final project for Theory of Crytography class. Our Image Encryption/Decryptio

Danny 5 Apr 11, 2022
BlockVis - Create beautiful visualizations of Bitcoin Blockheaders

BlockVis Create beautiful visualizations of Bitcoin Blockheaders How to run To r

Egge 2 Jan 05, 2022
A crypto wallet to send bnb and ether coin using web3.py and moralis speedy node

A crypto wallet to send bnb and ether coin using web3.py and moralis speedy node

Ciscoquan 3 Aug 16, 2022
This is a basic encryption and decryption program made in python.

A basic encryption and decryption program to visualize how the process of protecting data works.

Junaid Chaudhry 5 Nov 15, 2021
EncryptAGit - Encrypt Your Git Repos

EncryptAGit - Encrypt Your Git Repos

midnite_runr 25 Oct 06, 2022
dashboard to track crypto prices and change via the coinmarketcap APIs

crypto-dashboard Dashboard to track crypto prices and change via the coinmarketcap APIs. Uses chart.js and ag-grid. Requirements: python 3 (was writte

4 Nov 09, 2021
Using with Jupyter making live crypto currency action

Make-Live-Crypto-Currency-With-Python Using with Jupyter making live crypto currency action 1.Note: 💣 You must Create a Binance account and also clic

Mahmut Can Gönül 5 Dec 13, 2021
Advanced Digital Envelope System Using Cryptography Techniques (Encryption & Decryption)

Advanced-Digital-Envelope-System Advanced Digital Envelope System Using Cryptography Encryption Techniques The digital envelope system is the techniqu

NelakurthiSudheer 2 Jan 03, 2022
Hasher Hash, Compare and Verify your files Translations

Hasher Hash, Compare and Verify your files Translations In order to translate Hasher to a language you must add a folder with the language abbreviatio

Jeyson Flores 14 Apr 01, 2022
This is a webpage that contains login and signup page by which the password is stored using elliptic curve cryptography

LoginPage_using_Elliptic_curve_cryptography- This is a webpage that contains login and signup page by which the password is stored using elliptic curv

1 Oct 15, 2021
Encrypt Your Script Python

EncryptScritpPY Encrypt Your Script Python This Script For Encrypt Your File Python Tutorial Install [+] Open Termnal [+] Type: git clone https://gith

1 Oct 07, 2021
This folder contains all the assignment of the course COL759 : Cryptography & Computer Security

Cryptography This folder contains all the assignment of the course COL759 : "Cryptography & Computer Security" Assignment 1 : Encyption, Decryption &

0 Jan 21, 2022
Vaulty - Encrypt/Decrypt with ChaCha20-Poly1305

Vaulty Encrypt/Decrypt with ChaCha20-Poly1305 Vaulty is an extremely lightweight encryption/decryption tool which uses ChaCha20-Poly1305 to provide 25

Chris Mason 1 Jul 04, 2022
SHIBgreen is a cryptocurrency forked from Chia and uses the Proof of Space and Time consensus algorithm

SHIBgreen is a cryptocurrency forked from Chia and uses the Proof of Space and Time consensus algorithm

13 Jul 13, 2022
Kyrie Eleison - The best and unique way to encrypt some data or a file safely

Encrypt your important data and files easily and safely with Kyrie Eleison.

Billy 39 Oct 27, 2022