diff options
author | zysxqn@google.com <zysxqn@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 00:28:46 +0000 |
---|---|---|
committer | zysxqn@google.com <zysxqn@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 00:28:46 +0000 |
commit | 5eff57ede25d7fe51c3bb964aaba2745e3fb1896 (patch) | |
tree | f8cb338f8e22ce99a77903d4214dfda581857e38 /rlz/lib/string_utils.cc | |
parent | 2be6abf3a4fb590a1b59586858d1e49ea61f0708 (diff) | |
download | chromium_src-5eff57ede25d7fe51c3bb964aaba2745e3fb1896.zip chromium_src-5eff57ede25d7fe51c3bb964aaba2745e3fb1896.tar.gz chromium_src-5eff57ede25d7fe51c3bb964aaba2745e3fb1896.tar.bz2 |
Add a regenerate button to regenerate the password in Windows.
BUG=120480
TEST=Not tested.
Review URL: https://chromiumcodereview.appspot.com/10642009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'rlz/lib/string_utils.cc')
-rw-r--r-- | rlz/lib/string_utils.cc | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/rlz/lib/string_utils.cc b/rlz/lib/string_utils.cc deleted file mode 100644 index 50206a8..0000000 --- a/rlz/lib/string_utils.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// String manipulation functions used in the RLZ library. - -#include "rlz/lib/string_utils.h" - -#include "rlz/lib/assert.h" - -namespace rlz_lib { - -bool IsAscii(char letter) { - return (letter >= 0x0 && letter < 0x80); -} - -bool GetHexValue(char letter, int* value) { - if (!value) { - ASSERT_STRING("GetHexValue: Invalid output paramter"); - return false; - } - *value = 0; - - if (letter >= '0' && letter <= '9') - *value = letter - '0'; - else if (letter >= 'a' && letter <= 'f') - *value = (letter - 'a') + 0xA; - else if (letter >= 'A' && letter <= 'F') - *value = (letter - 'A') + 0xA; - else - return false; - - return true; -} - -int HexStringToInteger(const char* text) { - if (!text) { - ASSERT_STRING("HexStringToInteger: text is NULL."); - return 0; - } - - int idx = 0; - // Ignore leading whitespace. - while (text[idx] == '\t' || text[idx] == ' ') - idx++; - - if ((text[idx] == '0') && - (text[idx + 1] == 'X' || text[idx + 1] == 'x')) - idx +=2; // String is of the form 0x... - - int number = 0; - int digit = 0; - for (; text[idx] != '\0'; idx++) { - if (!GetHexValue(text[idx], &digit)) { - // Ignore trailing whitespaces, but assert on other trailing characters. - bool only_whitespaces = true; - while (only_whitespaces && text[idx]) - only_whitespaces = (text[idx++] == ' '); - if (!only_whitespaces) - ASSERT_STRING("HexStringToInteger: text contains non-hex characters."); - return number; - } - number = (number << 4) | digit; - } - - return number; -} - -bool BytesToString(const unsigned char* data, - int data_len, - std::string* string) { - if (!string) - return false; - - string->clear(); - if (data_len < 1 || !data) - return false; - - static const char kHex[] = "0123456789ABCDEF"; - - // Fix the buffer size to begin with to avoid repeated re-allocation. - string->resize(data_len * 2); - int index = data_len; - while (index--) { - string->at(2 * index) = kHex[data[index] >> 4]; // high digit - string->at(2 * index + 1) = kHex[data[index] & 0x0F]; // low digit - } - - return true; -} - -} // namespace rlz_lib |