Skip to content

Commit

Permalink
Add dice words
Browse files Browse the repository at this point in the history
  • Loading branch information
hschne committed Dec 12, 2023
1 parent 81cbc44 commit 8609e6e
Show file tree
Hide file tree
Showing 6 changed files with 7,840 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@
- [ ] Destroy data after access
- [ ] Destroy data after expiry


# FAQ

## Passwords & Security

To generate one-time-passwords the app utilizes the [Diceware method](https://std.com/~reinhold/diceware.html) with a slightly modifed Diceword list as provided by the [passphrase gem](https://github.com/esumbar/passphrase).

See also [cryptographic safety](https://blog.1password.com/1password-hashcat-strong-master-passwords/), [diceware at 1password](https://blog.1password.com/toward-better-master-passwords)
25 changes: 25 additions & 0 deletions app/models/dice_word.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# == Schema Information
#
# Table name: dice_words
#
# id :integer not null, primary key
# words :string
# created_at :datetime not null
# updated_at :datetime not null
#
class DiceWord < ApplicationRecord
def readonly?
true
end

class << self
def generate_password
ids = (1..4).map { (1..5).map { rand(1..6) }.join.to_i }
DiceWord
.find(*ids)
.map(&:words)
.map { |w| w.split(' ') }
.map { |t| t[rand(0..t.length - 1)] }.flatten.join('-')
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20231212173231_create_dice_words.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateDiceWords < ActiveRecord::Migration[7.1]
def change
create_table :dice_words do |t|
t.string :words

t.timestamps
end
end
end
14 changes: 13 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8609e6e

Please sign in to comment.