Skip to content

Commit 5d7bc6f

Browse files
Merge remote-tracking branch 'jdc/master'
2 parents 62badb8 + 7630e6e commit 5d7bc6f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

libs/commons-codec.jar

-45.6 KB
Binary file not shown.

libs/guava-r09.jar

-1.09 MB
Binary file not shown.

src/net/sqlcipher/DatabaseUtils.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import java.util.HashMap;
3333
import java.util.Map;
3434

35-
import org.apache.commons.codec.binary.Hex;
36-
3735
import android.content.ContentValues;
3836
import android.content.OperationApplicationException;
3937
import android.os.Parcel;
@@ -323,10 +321,23 @@ public static String getCollationKey(String name) {
323321
*/
324322
public static String getHexCollationKey(String name) {
325323
byte [] arr = getCollationKeyInBytes(name);
326-
char[] keys = Hex.encodeHex(arr);
324+
char[] keys = encodeHex(arr, HEX_DIGITS_LOWER);
327325
return new String(keys, 0, getKeyLen(arr) * 2);
328326
}
329327

328+
private static final char[] HEX_DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
329+
330+
private static char[] encodeHex(final byte[] data, final char[] toDigits) {
331+
final int l = data.length;
332+
final char[] out = new char[l << 1];
333+
// two characters form the hex value.
334+
for (int i = 0, j = 0; i < l; i++) {
335+
out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
336+
out[j++] = toDigits[0x0F & data[i]];
337+
}
338+
return out;
339+
}
340+
330341
private static int getKeyLen(byte[] arr) {
331342
if (arr[arr.length - 1] != 0) {
332343
return arr.length;

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
import android.util.Log;
5353
import android.util.Pair;
5454

55-
import com.google.common.collect.Maps;
56-
5755
/**
5856
* Exposes methods to manage a SQLite database.
5957
* <p>SQLiteDatabase has methods to create, delete, execute SQL commands, and
@@ -328,7 +326,7 @@ public static void loadLibs (Context context, File workingDir)
328326
* (@link setMaxCacheSize(int)}). its default is 0 - i.e., no caching by default because
329327
* most of the apps don't use "?" syntax in their sql, caching is not useful for them.
330328
*/
331-
/* package */ Map<String, SQLiteCompiledSql> mCompiledQueries = Maps.newHashMap();
329+
/* package */ Map<String, SQLiteCompiledSql> mCompiledQueries = new HashMap<String, SQLiteCompiledSql>();
332330
/**
333331
* @hide
334332
*/

0 commit comments

Comments
 (0)