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

Rubyのハッシュとパスワードのハッシュ化、まったく別物だと思っていませんか?

 Rubyのハッシュとパスワードのハッシュ化、まったく別物だと思っていませんか?

【iCARE Dev Meetup #36】Rejected CFP 供養会 2022 ( https://icare.connpass.com/event/261601/ )で発表した内容です。

Terai Shogo

November 16, 2022
Tweet

More Decks by Terai Shogo

Other Decks in Programming

Transcript

  1. 14 • ޮ཰ͷྑ͍୳ࡧΛߦ͏ͨΊ • ϋογϡ୳ࡧͰ͸ɺ୳ࡧʹ͔͔Δܭࢉྔ͸O(1)ͱઆ໌͞ΕΔ ϋογϡ୳ࡧ ྫɿϋογϡͷཁૉ਺͕1000000Ͱ΋ ɹɹkey͕ teraiͰ͋Δσʔλͷ୳ࡧʹ͸ 


    ɹɹཁૉ਺ʹൺྫͤͣɺҰఆͷ࣌ؒͰ୳ࡧՄೳ 1000000ݸ {terai: 178, … , endo: 196} key value ộ ộ ito 113 shiga 64 terai 178 ộ ộ
  2. 15 • ཁૉ਺͕๲େͰ΋Ұఆͷ࣌ؒͰܭࢉͰ͖Δͱ͍͏ͷ͸ຊ౰ͳͷ͔ʁ • ୯७ʹߟ͑Δͱɺ্͔ΒॱʹҰக͍ͯ͠Δ͔Λݟ͍ͯ͘ඞཁ͕ 
 ͋ΔͨΊɺཁૉ਺ n ʹൺྫͦ͠͏ 


    ϋογϡ୳ࡧ key value ộ ộ ito 113 shiga 64 terai 178 ộ ộ n ݸ ộ terai Ұக͍ͯ͠Δ͔ʁ Ұக͍ͯ͠Δ͔ʁ Ұக͍ͯ͠Δ͔ʁ ộ terai terai
  3. 20 • Ͱ͸ͲͷΑ͏ͳنଇʹैͬͯ֨ೲ͍ͯ͠Δͷ͔ʁ 1. ҰఆͷϝϞϦྖҬΛ֬อ͢ΔʢςʔϒϧαΠζʣ 2. key͔Βϋογϡ஋ΛٻΊΔ 3. ϋογϡ஋ΛςʔϒϧαΠζͰׂͬͨ༨ΓΛٻΊΔ 4.

    ͦͷ஋ΛΦϑηοτͱͯ֨͠ೲ͢ΔϝϞϦ൪஍Λܾఆ͢Δ ϋογϡςʔϒϧͷنଇ ϝϞϦ൪஍ key value ộ ộ ộ 0x1020 0x1024 0x1028 ộ 0x1408 ộ ộ ộ ςʔϒϧαΠζ͸1000
  4. 22 • Ͱ͸ͲͷΑ͏ͳنଇʹैͬͯ֨ೲ͍ͯ͠Δͷ͔ʁ 1. ҰఆͷϝϞϦྖҬΛ֬อ͢ΔʢςʔϒϧαΠζʣ 2. key͔Βϋογϡ஋ΛٻΊΔ 3. ϋογϡ஋ΛςʔϒϧαΠζͰׂͬͨ༨ΓΛٻΊΔ 4.

    ͦͷ஋ΛΦϑηοτͱͯ֨͠ೲ͢ΔϝϞϦ൪஍Λܾఆ͢Δ ϋογϡςʔϒϧͷنଇ ϋογϡؔ਺ terai d39a9902c2 ςʔϒϧαΠζ1000Ͱ 
 ׂͬͨ༨Γ 162
  5. 23 • Ͱ͸ͲͷΑ͏ͳنଇʹैͬͯ֨ೲ͍ͯ͠Δͷ͔ʁ 1. ҰఆͷϝϞϦྖҬΛ֬อ͢ΔʢςʔϒϧαΠζʣ 2. key͔Βϋογϡ஋ΛٻΊΔ 3. ϋογϡ஋ΛςʔϒϧαΠζͰׂͬͨ༨ΓΛٻΊΔ 4.

    ͦͷ஋ΛΦϑηοτͱͯ֨͠ೲ͢ΔϝϞϦ൪஍Λܾఆ͢Δ ϋογϡςʔϒϧͷنଇ 162 ϝϞϦ൪஍ key value ộ ộ ộ 0x1024 ộ 0x10C6 terai 178 ộ 0x1408 ộ ộ ộ ೖΕΔͳΒ͔͜͜͠ͳ͍ {terai: 178}
  6. 24 ϋογϡςʔϒϧ͔Β୳ࡧ͢Δͱ͖ 162 ϝϞϦ൪஍ key value ộ ộ ộ 0x1024

    ito 113 ộ 0x10C6 terai 178 ộ 0x1408 shiga 64 ộ ộ ộ ೖ͍ͬͯΔͳΒ͔͜͜͠ͳ͍ ্͔Βશ෦֬ೝ͠ͳͯ͘΋1ճͰ͍͚Δ • ಉ༷ͷखॱͰkey͔ΒΦϑηοτΛܭࢉ͢Δ͜ͱͰɺ 
 ϋογϡςʔϒϧ಺ͷ֬ೝ͢Ε͹ྑ͍ϝϞϦ൪஍ΛಛఆͰ͖Δ terai
  7. 26 • িಥ ϋογϡςʔϒϧͷ໰୊఺ ϋογϡؔ਺ terai 10162 ςʔϒϧαΠζ1000Ͱ 
 ׂͬͨ༨Γ

    162 niwa 20162 ςʔϒϧαΠζ1000Ͱ 
 ׂͬͨ༨Γ 162 takei 30162 ςʔϒϧαΠζ1000Ͱ 
 ׂͬͨ༨Γ 162 ςʔϒϧαΠζͰׂΔ͜ͱʹΑͬͯ 
 ςʔϒϧαΠζະຬʹม׵ͨ݁͠Ռ 
 ಉ͡஋ʹͳͬͯ͠·͏৔߹
  8. 27 ϋογϡςʔϒϧͷ໰୊఺ 162 ϝϞϦ൪஍ key value ộ ộ ộ 0x1024

    ito 113 ộ 0x10C6 ? ? ộ 0x1408 shiga 64 ộ ộ ộ ೖΕΔͳΒ͔͜͜͠ͳ͍ • িಥ͕ى͖Δͱ… {terai: 178} ೖΕΔͳΒ͔͜͜͠ͳ͍ {niwa: 211} ೖΕΔͳΒ͔͜͜͠ͳ͍ {takei: 362}
  9. 28 ༗໊ͳղܾ๏ • νΣΠϯ๏ • ΦʔϓϯΞυϨε๏ ϝϞϦ൪஍ ஋ ộ ộ

    0x1024 {ito: 113} ộ 0x10C6 ộ ộ {terai: 178} {niwa: 211} {takei: 362} ϝϞϦ൪஍ ஋ ộ ộ 0x1024 {ito: 113} ộ 0x10C6 {terai: 178} 0x10CA {niwa: 211} 0x10CE {takei: 362} ộ 0x1408 {shiga: 64} ộ ộ ͕࣌ؒͳ͍ͨΊ 
 ΞϧΰϦζϜͷઆ໌͸ׂѪ
  10. 38 • ࢲ͸ΤϯδχΞʹͳ͔ͬͯΒ·ͩ໿1೥ͰɺԿΛͱͬͯ΋ 
 ࣗ৴͕͋Δͱ͸ݴ͑·ͤΜ • ͔͠͠ɺRubyKaigiͱKaigi on RailsʹCFPΛग़ͯ͠Έ·ͨ͠ •

    CFPͷaccept / reject ΛܾΊΔͷ͸ӡӦଆͳͷͰɺ 
 ॳ৺ऀ͕ʢ΋͔ͨ͠͠ΒϨϕϧͷ௿͍ʣCFPΛఏग़ͯ͠΋ 
 ୭ʹ΋໎࿭͸͔͔Βͳ͍ͱࢥ͍·͢ • ࠷ॳ͸ΈΜͳॳ৺ऀͩͬͨ͸ͣ • Ή͠Ζॳ৺ऀͷൃද಺༰͕͞͞Δ૚΋͖ͬͱ͍Δ͸ͣ ॳ৺ऀͰ΋CFPΛग़ͯ͠ྑ͍ͱ͍͏͜ͱ
  11. 39 • CFPΛఏग़͢Δͱ͍͏ߦಈΛͨ͜͠ͱʹΑͬͯಘΒΕΔ 
 ஌ࣝ΍ܦݧɺਓͱͷग़ձ͍͕͋Δͱࢥ͍·͢ • ࠷ॳ͸ؾ͕Ҿ͚ͨΓͳ͔ͳ͔༐ؾ͕ग़ͳ͍͔΋͠Ε·ͤΜ͕ɺ 
 ࢲͷΑ͏ʹ஌ࣝ΍ܦݧ͕গͳ͍ਓ͕CFPΛग़ͯ͠΋ 


    ໎࿭͸͔͔͍ͬͯ·ͤΜ͠ɺग़ͯ͠Έͯྑ͔ͬͨͳͱײ͍ͯ͡·͢ • ΋͠໎͍ͬͯΔํ͕͓ΒΕͨΒɺ͜ͷ࿩͕ͦͷਓͷഎதΛԡ͢ 
 ͖͔͚ͬʹͳΔ͜ͱΛئ͍ͬͯ·͢ ॳ৺ऀͰ΋CFPΛग़ͯ͠ྑ͍ͱ͍͏͜ͱ
  12. 40 • Ruby master Feature #12142 
 ʢνΣΠϯ๏͔ΒΦʔϓϯΞυϨε๏΁ͷมߋͷఏҊ͕ߦΘΕͨ 
 ɹεϨουʣ

    • Rubyͷ഑ྻ(Array)Λຐվ଄ͯ͠ɺ࿈૝഑ྻͱͯ͠࢖ͬͯΈͨ 
 ʢϋογϡςʔϒϧͷنଇΛࢀߟʹͨ͠هࣄʣ ࢀߟʹͨ͠هࣄ