Upgrade to Pro — share decks privately, control downloads, hide ads and more …

はてなインターン応募RTA / Hatena Engineer Seminar #24 id:cockscomb

はてなインターン応募RTA / Hatena Engineer Seminar #24 id:cockscomb

Hatena Engineer Seminar #24 「はてなインターン完全攻略マニュアル」 https://developer.hatenastaff.com/entry/engineer-seminar-24 の資料です

Hatena

May 09, 2023
Tweet

More Decks by Hatena

Other Decks in Technology

Transcript

  1. ೥+40/4DIFNB ԠืΫΠζͷྺ࢙ w ༩͑ΒΕͨ+40/4DIFNBʹద߹ ͢Δ+40/ͰԠื { "$schema": "http: // json-schema.org/draft-04/schema#",

    "properties": { "accounts": { "description": "͋ͳ͕ͨར༻͍ͯ͠ΔΠϯλʔωοταʔϏεͷΞΧ΢ϯτ", "properties": { "hatena": { "description": "͸ͯͳͷΞΧ΢ϯτ໊", "type": "string" }, "github": { "description": "GitHubͷΞΧ΢ϯτ໊", "type": "string" } }, "type": "object" }, "languages": { "description": "͋ͳ͕ͨಘҙͳϓϩάϥϛϯάݴޠ(ΑΓಘҙͳݴޠॱ)", "items": { "type": "string" }, "type": "array" }, "portfolio": { "description": "MarkdownܗࣜͷࣗવจͰॻ͔Εͨ͋ͳͨͷϙʔτϑΥϦΦɻଞͷ߲໨ʹऩ ·Βͳ͍಺༰΍ɺิ଍͢Δࣄ߲ͳͲΛͳΜͰ΋ॻ͍ͯԼ͍͞ɻ", "type": "string" } }, "required": ["languages", "portfolio"], "type": "object", "additionalProperties": false }
  2. const encrypted = 's9Vo5kz2HD5y/H/I6ioBKweghEcM2zyoI9Hf74b4jxwALSgj9hk5V6dLe2LJZ/dVRXlO+FW6Kmv895UAhzN4WcDM40gYPN+PaT9hEBTwNyV2fxbe' const salt = new TextEncoder().encode(atob('MTY2LDYxLDIxOCwyMTMsMjQ5LDEwNiwyNDEsMjQzLDE3Myw2LDAsMTY0LDYxLDEyMiwyMzYsNzg=')) async

    function _convertPasscodeToKey(passcode) { const digest = await crypto.subtle.digest('SHA-256', (new TextEncoder()).encode(String(passcode).padStart(4, '0'))) const keyMaterial = await crypto.subtle.importKey('raw', digest, 'PBKDF2', false, ['deriveKey']) return await crypto.subtle.deriveKey( { name: 'PBKDF2', salt, iterations: 1, hash: 'SHA-256' }, keyMaterial, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'] ) } async function _decrypt(key, data) { const buffer = new Uint8Array(atob(data).split('').map((c) => c.charCodeAt(0))) const iv = buffer.slice(0, 12) const encrypted = buffer.slice(12) const decrypted = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, encrypted) return (new TextDecoder()).decode(decrypted) } async function unlock(passcode) { const key = await _convertPasscodeToKey(passcode) return await _decrypt(key, encrypted) }