Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ the substitution table, the sample list and the status messages together.

---

## 🎯 Use cases

### Ways of using this tool in particular

- Confirming that it is a simple substitution despite the figures (frequency-analysis classes): each letter maps to one dancing figure. Encrypting HELLO makes the same "L" the same figure twice, so repeated letters appear as repeated figures. Behind the exotic look it is a simple substitution, and you can confirm that counting the figures lets frequency analysis work
- Confirming that a flag marks word boundaries and leaks word lengths (cryptanalysis classes): the last figure of each word carries a flag. Encrypting HELLO WORLD raises a flag on the O at the end of the first word (the 5th letter). You can confirm that showing word breaks with a flag leaks the clue of word length and helps decryption (the same idea by which Sherlock Holmes started from short words)
- Confirming that all 26 letters map one to one to figures (substitution classes): each of the 26 letters of the alphabet is assigned one fixed figure. Since letters and figures are one to one, you can always turn a figure back into its letter. Behind the pictures it is a fixed substitution table with no key

### General uses

- Learn how the Dancing Men cipher (Sherlock Holmes) works in class or self-study
- Make figure ciphertext (SVG or image) to hand out at puzzles and events
- Use it as a subject for frequency analysis of a simple substitution cipher

## 🔒 Security and privacy

- A meta CSP allows scripts, styles and images from the same origin only. No inline handler and no `style` attribute is used
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,20 @@ JavaScriptが表示する文言は`dancingmen-messages.js`の辞書から`t`で
入力欄の内容と復号中の人形は残ります。

---
## 🎯 ユースケース

### このツールならではの使い方

- 見た目が人形でも単一換字式だと確かめる(頻度分析の授業):1文字が1体の踊る人形に対応する。HELLOを暗号化すると、同じ「L」が同じ人形に2回なり、くり返す字がくり返す人形で現れる。派手な見た目でも中身は単一換字式で、人形の出現頻度を数えれば頻度分析が効くことを確かめられる
- 旗が語の区切りを示し、語の長さが漏れることを確かめる(暗号解読の授業):各語の最後の人形には旗が付く。HELLO WORLDを暗号化すると、1語目の最後のO(5文字目)に旗が立つ。旗で語の切れ目がわかると、語の長さという手がかりが漏れ、解読を助けることを確かめられる(シャーロック・ホームズが短い語から解いたのと同じ考え方)
- 26文字すべてが人形に1対1で対応することを確かめる(置換の授業):アルファベット26文字のそれぞれに、決まった1体の人形が割り当てられている。文字と人形が1対1なので、人形から元の文字へ必ず戻せる。見た目は絵でも、鍵のない固定の置換表だと確かめられる

### 一般的な使い方

- 踊る人形暗号(シャーロック・ホームズ)のしくみを授業や自習で学ぶ
- 謎解きやイベントで、人形の暗号文(SVG・画像)を作って配る
- 単一換字式暗号の頻度分析の題材にする

## 🔒 セキュリティ

- meta CSPで同一オリジンのスクリプト・CSS・画像だけを許可。インラインイベントとstyle属性は不使用
Expand Down
14 changes: 14 additions & 0 deletions test/readme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,17 @@ test("README obsolete claims and non-existent code examples are absent", () => {
assert.ok(!readme.includes(obsolete), obsolete);
}
});

test("ユースケースの「このツールならではの使い方」を dancingmen-logic.js で再計算(日英)", () => {
const { encryptText, LETTERS } = require("../dancingmen-logic.js");
const en = fs.readFileSync(path.join(root, "README.en.md"), "utf8");
const hello = encryptText("HELLO")[0];
assert.deepEqual(hello.map((t) => t.letter), ["H", "E", "L", "L", "O"]);
assert.equal(hello[2].letter, hello[3].letter);
assert.equal(hello.filter((t) => t.letter === "L").length, 2);
const hw = encryptText("HELLO WORLD")[0];
assert.equal(hw[4].letter, "O");
assert.equal(hw[4].flag, true);
assert.equal(LETTERS.length, 26);
for (const md of [readme, en]) assert.ok(md.includes("HELLO WORLD") && md.includes("26"));
});
Loading