chrstntdd / dicephrase Goto Github PK
View Code? Open in Web Editor NEWSimple, random, and secure in-browser password generator
Home Page: https://dicephrase.xyz/
Simple, random, and secure in-browser password generator
Home Page: https://dicephrase.xyz/
Add an extra /diy
route to let folks lookup words on the wordlist directly with a datalist for cases when they want to roll their own dice.
Should also ensure proper visualization by using id
in cases where the name of an invoke
block is not inferred.
Description:
No validation exists for the CLI. Any args possible -- allows impossible states like a negative count and handles some characters strangely
Acceptance Criteria:
dicephrase
cli package validates the argumentsConcept:
URLSearchParams
.The "Ready to work offline" toast shows up multiple times. This should only happen once.
Given the current code:
let make_wl_keys = count => {
open Js.TypedArray2
let chunk_size = 5
let key_count = count * chunk_size
let raw_bits = Uint32Array.fromLength(key_count)
// Fill (mutates the raw_bits in place)
getRandomValues(raw_bits)
let min = 1
let max = 6
let rec bits_to_keys = (bits, acc, idx) => {
if mod(idx, chunk_size) == 0 {
acc
->Js.Array2.push(
bits
->Uint32Array.subarray(~start=idx, ~end_=idx + chunk_size)
->Uint32Array.map((. x) => {
let roll = mod(x, max) + min
roll
})
->Uint32Array.joinWith(""),
)
->ignore
}
if idx + 1 === key_count {
acc
} else {
bits_to_keys(bits, acc, idx + 1)
}
}
bits_to_keys(raw_bits, [], 0)
}
We have excessive iterations in the recursive bits_to_keys
function. As we recurse, we only increment the index. This causes the need for the if mod(idx, chunk_size) == 0
check at the beginning and thus we call more often, though the if
check avoids doing the more expensive operations.
To explain, this is what the current implementation would look like if we log the idx
each loop of bits_to_keys
when the count
is 6
:
0 // useful
1
2
3
4
5 // useful
6
7
8
9
10 // useful
11
12
13
14
15 // useful
16
17
18
19
20 // useful
21
22
23
24
25 // useful
26
27
28
29
As mentioned, the if
check is ensuring we can skip "expensive" work for the non-useful iterations , but theres a better way!
We can increase the idx
by the chunk size instead to avoid extra iterations and avoid the if
check to produce this output when logging idx
given the same input as above:
0
5
10
15
20
25
Some password requirements suggest more variations that currently are not supported such as:
Personally, I'll add the missing requirements myself, but it would be nice to have this handled natively.
Will require reconsideration of how the controls are laid out since the new fields might crowd the screen on smaller screen devices.
The apps/main-worker
workspace can be removed now โ it's dead code.
At this time, the App is entirely self contained in the browser. I once thought it would be nice to do SSR with Cloudflare workers for a progressive enhancement, but decided against it for simplicity & privacy.
This could change in the future, but for now it's best to be removed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.