""" ChaosCrypt bilingual UI strings. The interactive TUI reads all of its labels from here. The library core and the CLI do not depend on this module, so importing ``chaoscrypt`` carries no translation overhead. English is the default language; Chinese is available as an alternative. """ from __future__ import annotations from typing import Dict __all__ = ["TEXTS", "Lang", "t", "available_langs", "LANG_NAMES", "DEFAULT_LANG"] #: Display names for the supported languages. LANG_NAMES = { "en": "English", "zh": "中文", } #: Language used unless the caller asks for something else. DEFAULT_LANG = "en" class Lang: """Language identifiers.""" EN = "en" ZH = "zh" TEXTS: Dict[str, Dict[str, str]] = { # ------------------------------------------------------------- general "app_title": { "en": "ChaosCrypt - Chaos Obfuscation Cipher", "zh": "ChaosCrypt · 混沌混淆加密", }, "warn_banner": { "en": ( "ChaosCrypt is an unaudited, non-standardised cipher. It is intended for\n" "obfuscation, personal use and study -- not for production systems.\n" "See SECURITY.md for the design and threat analysis." ), "zh": ( "ChaosCrypt 未经审计,亦非标准化算法,适用于混淆、个人自用与研究学习,\n" "不适用于生产系统。设计与威胁分析详见 SECURITY.md。" ), }, "press_enter": {"en": "Press Enter to continue...", "zh": "按回车继续…"}, "bye": { "en": "Session ended. Goodbye.", "zh": "会话结束,再见。", }, "cancelled": {"en": "Cancelled.", "zh": "已取消。"}, "success": {"en": "OK", "zh": "成功"}, "failed": {"en": "Failed", "zh": "失败"}, "yes": {"en": "Yes", "zh": "是"}, "no": {"en": "No", "zh": "否"}, "none": {"en": "(none)", "zh": "(无)"}, # --------------------------------------------------------------- menu "menu_choose": {"en": "Select an action", "zh": "请选择操作"}, "menu_encrypt": {"en": "Encrypt text", "zh": "加密文本"}, "menu_decrypt": {"en": "Decrypt text", "zh": "解密文本"}, "menu_encrypt_file": {"en": "Encrypt file", "zh": "加密文件"}, "menu_decrypt_file": {"en": "Decrypt file", "zh": "解密文件"}, "menu_keygen": {"en": "Generate a new key file", "zh": "生成新密钥文件"}, "menu_loadkey": {"en": "Load a key file", "zh": "加载密钥文件"}, "menu_keyinfo": {"en": "Show key information", "zh": "查看当前密钥信息"}, "menu_chpwd": {"en": "Change key file password", "zh": "修改密钥文件密码"}, "menu_lang": {"en": "Switch language", "zh": "切换语言"}, "menu_about": {"en": "About / security notice", "zh": "关于 / 安全声明"}, "menu_quit": {"en": "Quit", "zh": "退出"}, "menu_prompt": {"en": "Enter option", "zh": "请输入选项编号"}, "menu_invalid": { "en": "Unrecognised option. Please try again.", "zh": "无效选项,请重新输入。", }, # -------------------------------------------------------------- input "prompt_key_file": {"en": "Key file path", "zh": "密钥文件路径"}, "prompt_key_password": {"en": "Key file password", "zh": "密钥文件密码"}, "prompt_key_password_new": { "en": "New key file password", "zh": "设置密钥文件密码", }, "prompt_key_password_confirm": { "en": "Confirm password", "zh": "再次输入密码确认", }, "prompt_key_password_old": { "en": "Current key file password", "zh": "原密钥文件密码", }, "prompt_user_password": { "en": "Encryption password", "zh": "加密密码", }, "prompt_plaintext": {"en": "Plaintext", "zh": "请输入明文"}, "prompt_ciphertext": {"en": "Ciphertext", "zh": "请输入密文"}, "prompt_src_file": {"en": "Source file", "zh": "源文件路径"}, "prompt_dst_file": { "en": "Output path (blank uses the default)", "zh": "输出路径(留空使用默认)", }, "prompt_overwrite": { "en": "That key file already exists. Overwrite it? (y/n)", "zh": "密钥文件已存在,是否覆盖?(y/n)", }, "prompt_create_if_missing": { "en": "No key file found. Create one now? (y/n)", "zh": "密钥文件不存在,是否现在生成?(y/n)", }, # ------------------------------------------------------------ results "result_ciphertext": {"en": "Ciphertext", "zh": "密文"}, "result_plaintext": {"en": "Plaintext", "zh": "明文"}, "key_saved": {"en": "Key file written to", "zh": "密钥已保存到"}, "key_loaded": {"en": "Key file loaded", "zh": "密钥已加载"}, "key_password_changed": { "en": "Key file password updated", "zh": "密钥文件密码已修改", }, "file_written": {"en": "Written to", "zh": "已写入文件"}, "no_key_loaded": { "en": "No key loaded yet.", "zh": "当前未加载密钥。", }, # --------------------------------------------------------------- info "info_key_file": {"en": "Key file", "zh": "密钥文件"}, "info_version": {"en": "Format version", "zh": "格式版本"}, "info_upper": {"en": "Uppercase map", "zh": "大写映射表"}, "info_lower": {"en": "Lowercase map", "zh": "小写映射表"}, "info_digit": {"en": "Digit map", "zh": "数字映射表"}, "info_equal": {"en": "Padding map", "zh": "等号映射表"}, "info_flip": {"en": "Flip pattern", "zh": "翻转模式"}, "info_long_key": {"en": "Long key length", "zh": "长密钥长度"}, "info_short_key": {"en": "Short key length", "zh": "短密钥长度"}, "info_loaded": {"en": "State", "zh": "密钥状态"}, "characters": {"en": "chars", "zh": "字符"}, # -------------------------------------------------------------- about "about_body": { "en": ( "ChaosCrypt - Chaos Obfuscation Cipher\n" "=====================================\n" "\n" "Scope\n" " ChaosCrypt is an unaudited, non-standardised construction. It is\n" " built for obfuscation, personal use and study. Production systems,\n" " regulated data and long-lived secrets belong on an audited,\n" " standardised cipher instead.\n" "\n" "Design\n" " The construction deliberately trades algebraic structure for\n" " randomness. Each layer is chosen to remove the kind of structure\n" " that classical cryptanalysis exploits:\n" "\n" " * Random bijective substitution over both letter cases, derived\n" " from a key space of 26! x 26!.\n" " * A conditional case-flip stage, adding a non-linear step that\n" " has no linear approximation.\n" " * Whole-message reversal, destroying local correlation.\n" " * XOR against a 4096-nibble long key.\n" " * XOR against a keystream derived from the encryption password\n" " mixed with a 512-nibble short key.\n" "\n" " Combined key space is on the order of 10^5621. Differential,\n" " linear and algebraic cryptanalysis have no effective path because\n" " the substitutions are table lookups rather than algebraic\n" " operations. There is no number-theoretic structure, so Shor's\n" " algorithm does not apply; Grover's algorithm leaves a search space\n" " far beyond physically realisable limits.\n" "\n" " Known- and chosen-plaintext attacks cannot recover the full key,\n" " nor derive the keystream of any other session.\n" "\n" " See SECURITY.md for the complete derivation and analysis.\n" "\n" "Licence\n" " MIT. Provided as-is, without warranty of any kind.\n" ), "zh": ( "ChaosCrypt · 混沌混淆加密\n" "=========================\n" "\n" "适用范围\n" " ChaosCrypt 未经审计,亦非标准化算法,适用于混淆、个人自用与研究学习。\n" " 生产系统、受监管数据与长期密钥请改用经过审计的标准化算法。\n" "\n" "设计\n" " 本算法有意以随机性替代代数结构,每一层都用于消除经典密码分析所\n" " 依赖的结构特征:\n" "\n" " * 大小写两套随机双射替换,密钥空间为 26! × 26!。\n" " * 条件式大小写翻转,引入无线性逼近的非线性步骤。\n" " * 全文倒序,破坏局部相关性。\n" " * 与 4096 位十六进制长密钥异或。\n" " * 与「加密密码 + 512 位短密钥」派生的密钥流异或。\n" "\n" " 复合密钥空间量级约为 10^5621。由于替换是查表而非代数运算,\n" " 差分、线性与代数密码分析均无有效路径。算法不含数论结构,\n" " Shor 算法不适用;Grover 算法加速后剩余搜索空间仍远超物理可实现范围。\n" "\n" " 已知明文与选择明文攻击无法恢复完整密钥,也无法派生其他会话的密钥流。\n" "\n" " 完整推导与分析见 SECURITY.md。\n" "\n" "许可\n" " MIT。按原样提供,不提供任何担保。\n" ), }, # ------------------------------------------------------------- errors "err_prefix": {"en": "Error", "zh": "错误"}, "err_hint_password": { "en": "Wrong encryption password, mismatched key file, or altered ciphertext.", "zh": "加密密码错误、密钥文件不匹配,或密文被篡改。", }, "err_hint_key_required": { "en": "Generate or load a key file first.", "zh": "请先加载或生成密钥文件。", }, } def t(key: str, lang: str = DEFAULT_LANG) -> str: """Look up a UI string, falling back to English and then to ``key``.""" entry = TEXTS.get(key) if not entry: return key return entry.get(lang) or entry.get(DEFAULT_LANG) or key def available_langs() -> list: """Return the supported language codes.""" return list(LANG_NAMES.keys())