# 散列 Hash https://zh.wikipedia.org/wiki/%E6%95%A3%E5%88%97%E5%87%BD%E6%95%B8 ---- - 散列函数把消息或数据压缩成摘要,使得数据量变小 - 如果两个散列值是不相同的(根据同一函数),那么这两个散列值的原始输入也是不相同的 - 好的散列函数在输入域中很少出现散列冲突 - 冲突少意味着很难找到产生相同散列值的数据 ---- F = X % 100 F(1) = F(101) = F(xx01) = 1 ---- MD5 SHA-256 --- # 区块链 Blockchain https://en.wikipedia.org/wiki/Blockchain https://academy.horizen.global/technology/advanced/blockchain-as-a-data-structure/ ---- ![linkedlist](https://academy.horizen.global/assets/post_files/technology/advanced/blockchain-as-a-data-structure/linked_list_D.jpg) ---- ![Blockchain](https://academy.horizen.global/assets/post_files/technology/advanced/blockchain-as-a-data-structure/blockchain_data_D.jpg) ---- ![](https://academy.horizen.global/assets/post_files/technology/advanced/blockchain-as-a-data-structure/blockchain_broken_D.jpg) --- # p2p 分布式 共识 --- ## Hashcash https://en.wikipedia.org/wiki/Hashcash ---- 生成需要大量计算,验证需要很少计算 Hash(content + nounce) < 100000000 101010101010 000111010001 000011010101 --- ## 工作量证明 POW ![](https://shentilium.com/static/images/blockbench/blockchain-data-structure.png) --- # 比特币 --- ## 非对称加密 --- ## 记账 --- ## Who am I? - Front-end developer - VSCode :heart: - I use tabs. :cat: --- ### 70% of our users are developers. Developers :heart: GitHub. --- {%youtube E8Nj7RwXf0s %} --- ### Usage flow --- ```graphviz digraph { compound=true rankdir=RL graph [ fontname="Source Sans Pro", fontsize=20 ]; node [ fontname="Source Sans Pro", fontsize=18]; edge [ fontname="Source Sans Pro", fontsize=12 ]; subgraph core { c [label="Hackmd-it \ncore"] [shape=box] } c -> sync [ltail=session lhead=session] subgraph cluster1 { concentrate=true a [label="Text source\nGithub, Gitlab, ..."] [shape=box] b [label="HackMD Editor"] [shape=box] sync [label="sync" shape=plaintext ] b -> sync [dir="both"] sync -> a [dir="both"] label="An edit session" } } ``` --- ### Architecture of extension --- ![](https://i.imgur.com/ij69tPh.png) --- ## Content script - Bind with each page - Manipulate DOM - Add event listeners - Isolated JavaScript environment - It doesn't break things --- # :fork_and_knife: --- <style> code.blue { color: #337AB7 !important; } code.orange { color: #F7A004 !important; } </style> - <code class="orange">onMessage('event')</code>: Register event listener - <code class="blue">sendMessage('event')</code>: Trigger event --- # :bulb: --- - Dead simple API - Only cares about application logic --- ```typescript import * as Channeru from 'channeru' // setup channel in different page environment, once const channel = Channeru.create() ``` --- ```typescript // in background script const fakeLogin = async () => true channel.answer('isLogin', async () => { return await fakeLogin() }) ``` <br> ```typescript // in inject script const isLogin = await channel.callBackground('isLogin') console.log(isLogin) //-> true ``` --- # :100: :muscle: :tada: --- ### Wrap up - Cross envornment commnication - A small library to solve messaging pain - TypeScript Rocks :tada: --- ### Thank you! :sheep: You can find me on - GitHub - Twitter - or email me
{"metaMigratedAt":"2023-06-15T02:06:31.050Z","metaMigratedFrom":"YAML","title":"小白讲区块链","breaks":true,"description":"https://zh.wikipedia.org/wiki/散列函數","contributors":"[{\"id\":\"35c6b9a5-1892-48a7-ac13-054a74325ece\",\"add\":3351,\"del\":83}]"}
    431 views