Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Util tweaks #63

Merged
merged 2 commits into from
May 22, 2016
Merged

Util tweaks #63

merged 2 commits into from
May 22, 2016

Conversation

gabriel
Copy link
Contributor

@gabriel gabriel commented May 9, 2016

  • Move rand util stuff into rand.go
  • RandString changed to RandomID and uses 256 bits
  • Move string util into strings.go

- Move rand util into rand.go
- RandString changed to RandomID and uses 256 bits
- Move string util into strings.go
@gabriel
Copy link
Contributor Author

gabriel commented May 19, 2016

@keybase/updater-hackers

if !strings.HasPrefix(s, "prefix.") {
t.Errorf("Invalid prefix: %s", s)
}
if len(s)-len("prefix.") != 52 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this actually work if the random number encodes with padding (which then gets removed)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, yeah the padding remove should only happen from the returned base32 string. Fixed with test.

if !strings.HasPrefix(s, "prefix=") {
t.Errorf("Invalid prefix: %s", s)
}
if len(s)-len("prefix.") != 52 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even with the above fix won't this fail sometimes? sometimes the base32 encoding will have padding / won't (or is that not true). It seems like if it does sometimes and doesn't sometimes, then the length of the random string (ignoring prefix) will be variable length (cause we strip it sometimes) so it won't always be 52 long. like sometimes it'll be 51 and still be working fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah.. the random id is always 256 bits (as suggested by https://gist.github.com/tqbf/be58d2d39690c3b366ad)... this means the padding will always be the same

@gabriel gabriel merged commit e37fa0a into master May 22, 2016
@gabriel gabriel deleted the utilrand branch May 22, 2016 19:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants