password.pug 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. extends layout
  2. block content
  3. p.
  4. Bla bla bla qui devi scegliere una buona password
  5. cosa puoi provare:
  6. li cia0Antaniqwer10102018
  7. li Tr0ub4dour&3
  8. br
  9. #app(v-cloak)
  10. input(
  11. type='password',
  12. v-model='password',
  13. @input='checkStrength'
  14. :class="['score' + estimationScore]"
  15. )
  16. button(:disabled="estimationScore!==4") ➜
  17. p(v-if='password.length>2').
  18. Questa password è {{score[estimationScore]}}, dopo un sequestro uno bravo
  19. ci mette più o meno <b>{{slowCrackTime}}</b> a scoprirla,
  20. la CIA circa <b>{{fastCrackTime}}</b>:
  21. li(v-for="s in sequence")
  22. span(v-if="s.pattern=='bruteforce'") {{s.token}} forza bruta
  23. span(v-else-if="s.pattern=='dictionary'").
  24. {{s.token}} dizionario: {{s.dictionary_name}}
  25. {{s.reversed?'(invertita ' + s.matched_word + ')':''}}
  26. {{s.l33t?'(con sostituzione ' + s.sub_display +')':''}}
  27. {{s.uppercase_variations>1?'(con maiuscola)':''}}
  28. span(v-else-if="s.pattern=='sequence'") {{s.token}} sequenze: ({{s.sequence_name}})
  29. span(v-else-if="s.pattern=='spatial'") {{s.token}} sequenze spaziali: ({{s.graph}})
  30. span(v-else-if="s.pattern=='repeat'") {{s.token}} ripetizione: ({{s.base_token}})
  31. span(v-else-if="s.pattern=='date'") {{s.token}} data {{s.day}}/{{s.month}}/{{s.year}}
  32. span(v-else-if="s.pattern=='regex'") {{s.token}} pattern {{s.regex_name}}
  33. span(v-else) {{s}}
  34. script(src='/js/vue.min.js')
  35. script(src='/js/zxcvbn.js')
  36. script(src='/js/moment.js')
  37. script.
  38. moment.locale('it');
  39. var app = new Vue({
  40. el: '#app',
  41. data: {
  42. password: '',
  43. estimationScore: 0,
  44. score: ['inutile', 'pessima', 'brutta', 'così così', 'buona'],
  45. scoreColor: 'red',
  46. slowCrackTime: '',
  47. fastCrackTime: '',
  48. sequence: [],
  49. },
  50. methods: {
  51. checkStrength (e) {
  52. var estimation = zxcvbn(this.password)
  53. this.estimationScore = estimation.score;
  54. this.slowCrackTime = moment.duration(estimation.crack_times_seconds.offline_slow_hashing_1e4_per_second, 'seconds').humanize();
  55. this.fastCrackTime = moment.duration(estimation.crack_times_seconds.offline_fast_hashing_1e10_per_second, 'seconds').humanize();
  56. this.sequence = estimation.sequence;
  57. }
  58. }
  59. })