Session tokens, temporary filenames and request identifiers all need a random
string, and the version people reach for first tends to use math/rand, which
is predictable and unsafe for anything a stranger should not be able to guess.
A single obvious function that reads from the system random source makes the
safe choice the default one.
Definition of done: RandomHexString(byteLength int) (string, error) returns
byteLength random bytes from crypto/rand written as lowercase hexadecimal, so
the string is twice as long as byteLength, and returns an error for a negative
length or if the random source fails. It has a doc comment and table-driven
tests covering the length of the result for several sizes, a length of zero, a
negative length, and that two calls do not return the same string.
Model: opus-5
Session tokens, temporary filenames and request identifiers all need a random
string, and the version people reach for first tends to use `math/rand`, which
is predictable and unsafe for anything a stranger should not be able to guess.
A single obvious function that reads from the system random source makes the
safe choice the default one.
Definition of done: `RandomHexString(byteLength int) (string, error)` returns
byteLength random bytes from `crypto/rand` written as lowercase hexadecimal, so
the string is twice as long as byteLength, and returns an error for a negative
length or if the random source fails. It has a doc comment and table-driven
tests covering the length of the result for several sizes, a length of zero, a
negative length, and that two calls do not return the same string.
Model: opus-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Session tokens, temporary filenames and request identifiers all need a random
string, and the version people reach for first tends to use
math/rand, whichis predictable and unsafe for anything a stranger should not be able to guess.
A single obvious function that reads from the system random source makes the
safe choice the default one.
Definition of done:
RandomHexString(byteLength int) (string, error)returnsbyteLength random bytes from
crypto/randwritten as lowercase hexadecimal, sothe string is twice as long as byteLength, and returns an error for a negative
length or if the random source fails. It has a doc comment and table-driven
tests covering the length of the result for several sizes, a length of zero, a
negative length, and that two calls do not return the same string.
Model: opus-5