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

Amazing CryptoWAF was a CTF challenge for ALLES! CTF 2021

ctf-cryptowaf The AmazingCryptoWAF ™️ is used by the "noter" web app, to offer automagically military encryption for any user data. Even if an attacke

32 Jan 02, 2023
Vhost password decrypt for python

vhost_password_decrypt Where is symkey.dat Windows:C:\ProgramData\VMware\vCenterServer\cfg\vmware-vpx\ssl\symkey.dat Linux:/etc/vmware-vpx/ssl/symkey.

Jing Ling 152 Dec 22, 2022
A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided

A bot written in Python to automatically buy tokens on the Binance Smart Chain as soon as liquidity is provided. If you’ve found this bot useful and have profited from it please consider donating any

473 Dec 25, 2022
Alpkunt 9 Sep 09, 2022
A repository for Algogenous Smart Contracts created on the Algorand Blockchain.

Smart Contacts This Repository is dedicated to code for Alogrand Smart Contracts using Choice Coin. Read Docs for how to implement Algogenous Smart Co

Choice Coin 3 Dec 20, 2022
A discord bot to crop an NFT image living on the Solana blockchain.

NFT Discord Cropper This discord bot crops an NFT in your set measures by getting it through the .cache file which has been used to make a candy machi

Rude Golems 7 Mar 21, 2022
Discord webhooks for alerting crypto currency price changes & historical data.

Crypto-Discord Discord Webhooks for alerting crypto currency price changes & historical data. Create virtual environment and install requirements. $ s

Филип Арсовски 1 Sep 02, 2022
Block Chain for RiceSupply Chain and Agriculture Traceability

Block Chain for RiceSupply Chain and Agriculture Traceability Project Under Development Folder: Building a BlockChain Basic blockchain structure using

Chandru S Raghavan 3 Jan 19, 2022
Looks for Bitcoin Wallets starting 1 compresses and Uncompressesed, segwit address and MultiSig starting 3.

Looks for Bitcoin Wallets starting 1 compresses and Uncompressesed, segwit address and MultiSig starting 3. Pick your starting and stop numbers to start looking. Need a database of addresses to check

10 Dec 22, 2022
XMRiGUI is free and open-source crypto miner for Linux. It uses XMRig for mining and GTK3 for GUI.

XMRiGUI is free and open-source crypto miner for Linux. It uses XMRig for mining and GTK3 for GUI.

29 Jul 07, 2022
offline half-random brute force script for Ethereum private keys

eth200swinger offline half-random brute force script for Ethereum private keys, goes from the beginning to end of range and vice versa, saves any foun

2 Oct 06, 2022
A cairo port for Rari Capital Vaults

crypts • Architecture contracts ├─ CryptFactory — "Factory for deploying Crypt contracts for any ERC20 token." ├─ Crypt — "Flexible, minimalist, and g

alucard 9 Sep 02, 2022
DCAStack: an Automated Dollar Cost Averaging Bot for Your Crypto

Welcome to DCA Stack! An Automated Dollar Cost Averaging Bot For Your Crypto Web

0 Sep 03, 2022
SimpleWallet - Simple wallet for Bitcoin

Simple Wallet This is a basic python starter package to be used as a template fo

Mystic 1 Jan 08, 2022
SDU experiment of introduction to the cryptography

Lab 01 (2 hrs): Programming Basics Program 1: Type Hint, String, Bytes, Hex, Base64 Lab 02 (4 hrs): Classical Cryptography Part 1 (3 hrs): Program 1:

1 Jan 03, 2022
A python tool to track prices of various cryptocurrencies and alert

CryptoPriceTracker This is a tool to track prices of various cryptocurrencies and alert the user once the user defined maximum & minimum target is rea

1 Oct 01, 2021
A bot that escrows crypto transactions on Reddit

EscrowBot I NEED BCH TESTNET FOR TESTING. Please send me some BCH testnet if you have some: bchtest:qz5eur3prqyvd8u77m6fzf9z6cruz9q7vq4qvgdnuk Depende

Nathan Lim 10 Nov 10, 2022
Gold(Gold) is a modern cryptocurrency built from scratch, designed to be efficient, decentralized, and secure

gold-blockchain (Gold) Gold(Gold) is a modern cryptocurrency built from scratch, designed to be efficient, decentralized, and secure. Here are some of

zcomputerwiz 3 Mar 09, 2022
PytoPrice is an automation program to fetch the latest price of a cryptocurrency of your choice at a user-customizable update interval.

PyToPrice (Python Crypto Price) PytoPrice is an automation program to fetch the latest price of a cryptocurrency of your choice at a user-customizable

Peter 1 Jun 16, 2022
Zero-dependency Cryptography Python Module with a self made method

TesohhCrypt TesohhCrypt is a zero-dependency Cryptography Python Module, with a method that i made. (likely someone already made a similar one, but i

Simone Tesini 1 Oct 26, 2021