NISRA
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Crypto :::danger 請愛惜共筆,勿進行惡意刪減 ::: :::warning [NISRA CTF](https://class.enlightened.nisra.net/) **此為本堂課上課用的教材** **請大家於課前先下載** - [for學員](https://drive.google.com/drive/folders/1liPpCvpAYr2U_Y6CF5DI4ssHBX8BwZ1Q) ::: **羅納德·李維斯特:"密碼學是關於如何在敵人存在的環境中通訊"** :::spoiler Table of Content [TOC] ::: ## 名詞介紹 - 明文 Plaintext - 加密前的原始訊息 (可閱讀) - 密文 Ciphertext - 加密後的訊息 (無法閱讀) - 加密 Encrypt - 把明文轉成密文的程序 - 解密 Decrypt - 把密文轉成明文的程序 - 金鑰/密鑰 Key - 加解密時使用的「鑰匙」 ## 柯克霍夫原則 1883年 柯克霍夫提出六個原則 兩個比較重要的: 1. 即使用**數學**可被破解 但在**實際程度**上應該無法破解 2. 即使**加密方式公開** 只要**密鑰安全** 仍然不能破譯 ## 密碼學分類 ```graphviz graph{ 古典密碼學 -- {移項式加密 替換式加密} 替換式加密 -- {單表加密 多表加密} } ``` ## 移項式加密 - Def : 位置改變,內容不變 ### 藏頭詩/藏頭新聞 * 移動資訊位置來呈現內容 ### 密碼棒 Scytale (柵欄加密 Rail fence cipher) ![](https://i.imgur.com/XsIqP9H.png) * 由夾帶訊息的皮革繞在一個木棒上組成 * 古希臘 斯巴達人用在軍事上 * 解密方式:使用相同尺寸的棒子將密文上面解讀 :::spoiler Example `KILLKINGTOMORROWMIDNIGHT` $\downarrow$ ``` KILLKING 147... TOMORROW 258... MIDNIGHT 369... ``` $\downarrow$ `KTMIOILMDLONKRIIRGNOHGMT` ::: ### Lab 01 - 密文: `MSTIYTAPFSLHICEERYCR` - Hint: - 長寬 4 x 5 的加密棒加密 ### 中國式密碼 ![](https://i.imgur.com/LsmhuZB.png) ## 替換式加密 - Def : 位置不變,內容改變 ### 凱薩密碼 - 一種替換加密技術 - 一個明文字元加密成一個密文字元 - 例如偏移量為2 - 所有字母A被替換成C、B被替換成D,以此類推 ``` ABCDEFGHIJKLMNOPQRSTUVWXYZ ↓↓↓↓↓↓↓↓(向下對照)↓↓↓↓↓↓↓↓↓ XYZABCDEFGHIJKLMNOPQRSTUVWXYZ ``` #### 密碼盤 ![](https://i.imgur.com/uXhkaAa.png) 內圈:明文 外圈:密文 ### LAB 02 - 密文: `JLUWNCWY` - 已知密文是被'U'凱薩加密的,則明文為? ### 阿特巴希密碼 - 將字母表整個扭轉: 第一個字母 "A" 與最後一個 "Z" 替換 第二個 "B" 與倒數第二個 "Y" 替換 ``` ABCDEFGHIJKLMNOPQRSTUVWXYZ ↓↓↓↓↓↓↓↓(向下對照)↓↓↓↓↓↓↓↓↓ ZYXWVUTSRQPONMLKJIHGFEDCBA ``` ### 簡易替換密碼<br>^替換表^ ![](https://i.imgur.com/gwCqVha.png) - 傳統上會先把一個關鍵詞寫在字母表最前面 再刪去重複字母 - 英文字母替換表最多有26!種 可以對替換表進行偏移~(凱撒密碼)~或翻轉~(阿特巴希密碼)~ :::spoiler 聊天室嗨起來 > 註解請進編輯模式 > [name=馬後炮404][time=Sat, Aug 14, 2021 11:23 PM] > 注音符號也可以吧 > [name=zhengtingliu0104] > 注音加密本身不就很強了(X > [name=404] > 只有台灣人解得出來(? > [name=zhengtingliu0104] > xu4bj65k4u;4 <!-- 例如這樣 --> > [name=404] > ji3g4au4a83 <!-- 我是密碼 --> > [name=LAVI] > yjo4fu;62k7ru8 au4fu6g6g4j;4ru4fu, 5j4up 187 <!-- 最強的加密其實是忘記切注音吧 --> > [name=s910246] > 5k4g4s83eiji6m3u06 <!-- 這是哪國語言 --> > [name=zhengtingliu0104] > 精靈族語 > [name=yuhaodai920404] > 要穿越異世界了嗎(X > [name=李若榛] > ㄓㄨㄥ ㄍㄨㄛˊ ㄖㄣˊ ㄎㄢˋ ㄅㄨˋ ㄉㄨㄥˇ > [name=forensic7306] ::: ### 波雷費密碼 Playfair cipher 1. 明文預處理 1. 將明文分成兩個字元一組。 2. 若一組內的字母相同,將"X"插入兩字母之間,重新分組。 3. 若最後一組剩下一個字,也加入"X" 2. 生成簡易密碼 - 選取一個關鍵字,然後製作一個簡易替換密碼 3. 建立5*5的表格 `P L A Y F I R B C D E G H K M N O Q S T U V W X Z` $\downarrow$ ``` P L A Y F I R B C D E G H K M N O Q S T U V W X Z ``` 4. 加密 1. 若兩個字元不在同一直行或同一橫列: * 在矩陣中找出另外兩個字母,使這四個字母成為一個長方形的四個角。 2. 若兩個字元在同一橫行: * 取這兩個字母右方的字母(若字母在最右方則取最左方的字母)。 3. 若兩個字元在同一直列: * 取這兩個字母下方的字母(若字母在最下方則取最上方的字母)。 :::spoiler Example 已預處裡明文:`WE LC OM ET ON IS RA EN LI GH TE NE DX` 5 * 5表格: ``` P L A Y F I R B C D E G H K M N O Q S T U V W X Z ``` `WE`:![](https://i.imgur.com/QZSXjh0.png) `LC`:![](https://i.imgur.com/kvjTBzy.png) `ON`:![](https://i.imgur.com/m94cA3a.png) `EN`:![](https://i.imgur.com/qibvXRh.png) ::: ### LAB 03 ### 四方密碼 > 波雷費密碼 ***PRO*** - 四方密碼共有4個5X5的表格 以每排兩個表格進行排列 - 單位表格 ![](https://i.imgur.com/w8lkOgR.png) - 生成表格: ![](https://i.imgur.com/Wq0mG4C.png) 左上右下為單位表格 右上左下選兩個單字 用波雷費的方式建表 - 假設明文為 `VENI VIDI VICI` ![](https://i.imgur.com/ofsyiRH.png) ![](https://i.imgur.com/g9SVIif.png) 解密跟波雷費類似 ## 編碼 - 不會修改資料內容 - 沒有任何加密的效果 - 單純就是換個方式來表達資料 > 換句非人話說== > [name=yu0412015] ### 摩斯編碼 ![](https://i.imgur.com/MdSsn5q.png) ## 單表加密攻擊:字頻分析 - 大部分語言中 字母或字符使用的頻率並不是平均的 - 以英文為例 母音 `A, E, I, O, U` 的使用頻率更高 - 單表加密只替換字元 頻率不變 > 吳鮭魚 > [name=CHA] ### 維吉尼亞密碼 - 很多層凱薩密碼 - 凱撒密碼轉一次密碼盤 維吉尼亞一個字轉一次 ### 多表加密攻擊 ![](https://i.imgur.com/SKqOLSW.png) - **I**ndex **o**f **c**oincidence(巧合指數) 白話版:文字的BMI - IoC ↑:加工啦哪次不加 IoC ↓:天然A尚好 - **完全隨機** → IoC 逼近 1 (下限) - 字母 ↑ IoC 上限 ↑ #### 一次性密碼本 - 規則 - 關鍵字**完全隨機** - **長度**:關鍵字 = 明文 - 只能用一次 - 缺點 - 實用性差 ![](https://i.imgur.com/P1HMBnA.png =200x200) ### Enigma - 鍵盤 + 接線板 + 轉子 + 反射器 + 燈盤 - 五個轉子選三個 $P^5_3$ 種排序 - 一個轉子就是一個替換表 - **多**個轉子還是**一個**替換表 - 反射器 還是一個替換表(半表) ex. `A`->`Y`,那就代表 `Y`->`A` * 維吉尼亞密碼 但密鑰長度為 26^3^ - 加密 & 解密 - 加、解密者須規定好 1. 使用的的轉子 2. 轉子擺放順序 3. **每個**轉子的起始位置 4. 接線板的設置 - 加密者 - 打明文記密文 - 解密者 - 打密文記明文 > Enigma 每一個狀態都是一個替換表~(一個電路)~ > 解密順著原路返回即可 ![](http://programmermagazine.github.io/mag/ymag201504/633px-Enigma-action.svg.png) ###### tags: `Enlightened` `NISRA` `2021` <style> .navbar-brand::after { content: " × NISRA"; } </style>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully