-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: add proper printing of sha256 passwords #1728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
kostasrim
commented
Aug 23, 2023
- Properly print sha256 passwords by converting hex values to characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had some utility like this somewhere 🤷
I will take a look before I merge, last time I checked I couldn't find anything |
Couldn't find anything, I imagine it would use I will move this at some point to a utility header, but it's a non priority for now |
absl::CHexEscape
…On Thu, Aug 24, 2023 at 9:59 AM Kostas Kyrimis ***@***.***> wrote:
I will take a look before I merge, last time I checked I couldn't find
anything
Couldn't find anything, I imagine it would use isdigit (which I used to
grep it) but nothing relevant came up).
I will move this at some point to a utility header, but it's a non
priority for now
—
Reply to this email directly, view it on GitHub
<#1728 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4BFCBDMMXW2UDRMESZJZLXW33VFANCNFSM6AAAAAA33VEHZA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Roman Gershman
CTO
---
*www.dragonflydb.io <http://www.dragonflydb.io>*
|
It's not escaping. The SHA is essentially a uint8_t[] (just stored in a string) and he wants to print it compactly, so his code is actually string out;
for (char c: password)
absl::StrAppend(&out, absl::Hex(c)); to get smth like this
|
True, but not every instead of
And I like the second more, so I will make this change :D |
Uh and you can't because |
There's |
src/server/acl/acl_family.cc
Outdated
for (size_t i = 0; i < 15; ++i) { | ||
absl::StrAppend(&result, absl::Hex(pass[i])); | ||
} | ||
|
||
result.resize(15); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- What about the leading digit? [1, 1] should be
0101
I thinks its better to use what Roy found 😝
// BytesToHexString()
//
// Converts binary data into an ASCII text string, returning a string of size
// `2*from.size()`.
std::string BytesToHexString(absl::string_view from);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%
(*cntx)->StartArray(registry.size()); | ||
|
||
auto pretty_print_sha = [](std::string_view pass) { | ||
return absl::BytesToHexString(pass.substr(15)).substr(15); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand 😄 bytes to hex string returns a string of length 30 (twice the size), why do you need only half of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I want to print up to 15 characters :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I'm just gonna trust you on this one 🤣