Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: rlz/lib/crc32_wrapper.cc

Issue 10642009: Add a regenerate button to regenerate the password in Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Sync and Merge. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « rlz/lib/crc32_unittest.cc ('k') | rlz/lib/crc8.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // A wrapper around ZLib's CRC functions to put them in the rlz_lib namespace
6 // and use our types.
7
8 #include "rlz/lib/assert.h"
9 #include "rlz/lib/crc32.h"
10 #include "rlz/lib/string_utils.h"
11 #include "third_party/zlib/zlib.h"
12
13 namespace rlz_lib {
14
15 int Crc32(const unsigned char* buf, int length) {
16 return crc32(0L, buf, length);
17 }
18
19 bool Crc32(const char* text, int* crc) {
20 if (!crc) {
21 ASSERT_STRING("Crc32: crc is NULL.");
22 return false;
23 }
24
25 *crc = 0;
26 for (int i = 0; text[i]; i++) {
27 if (!IsAscii(text[i]))
28 return false;
29
30 *crc = crc32(*crc, reinterpret_cast<const unsigned char*>(text + i), 1);
31 }
32
33 return true;
34 }
35
36 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « rlz/lib/crc32_unittest.cc ('k') | rlz/lib/crc8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698