diff options
author | Andrew Dolgov <[email protected]> | 2012-10-29 19:30:35 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-10-29 19:30:35 +0400 |
commit | 677699414dbdda250fcdf71a5e51b60ef370cbaa (patch) | |
tree | 27f82db8a37b9edbe3196d976ebf85449462d370 | |
parent | 20447a48aee4b4927afa8538835a4e7026d7c164 (diff) |
fix sha1 crashing on null string
-rw-r--r-- | AndroidManifest.xml | 4 | ||||
-rw-r--r-- | src/org/fox/ttcomics/CommonActivity.java | 28 |
2 files changed, 17 insertions, 15 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8af5b37..e1373a4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttcomics"
- android:versionCode="21"
- android:versionName="1.0.9" >
+ android:versionCode="22"
+ android:versionName="1.0.10" >
<uses-sdk
android:minSdkVersion="8"
diff --git a/src/org/fox/ttcomics/CommonActivity.java b/src/org/fox/ttcomics/CommonActivity.java index bc936e0..0245d78 100644 --- a/src/org/fox/ttcomics/CommonActivity.java +++ b/src/org/fox/ttcomics/CommonActivity.java @@ -367,19 +367,21 @@ public class CommonActivity extends FragmentActivity { }
protected static String sha1(String s) {
- try {
- MessageDigest digest = java.security.MessageDigest.getInstance("SHA1");
- digest.update(s.getBytes());
- byte messageDigest[] = digest.digest();
-
- StringBuffer hexString = new StringBuffer();
- for (int i=0; i<messageDigest.length; i++)
- hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
-
- return hexString.toString();
-
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
+ if (s != null) {
+ try {
+ MessageDigest digest = java.security.MessageDigest.getInstance("SHA1");
+ digest.update(s.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ StringBuffer hexString = new StringBuffer();
+ for (int i=0; i<messageDigest.length; i++)
+ hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
+
+ return hexString.toString();
+
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
}
return null;
|