diff options
Diffstat (limited to 'main/src/cgeo/geocaching/utils/CryptUtils.java')
| -rw-r--r-- | main/src/cgeo/geocaching/utils/CryptUtils.java | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/utils/CryptUtils.java b/main/src/cgeo/geocaching/utils/CryptUtils.java index f04327e..df2baa0 100644 --- a/main/src/cgeo/geocaching/utils/CryptUtils.java +++ b/main/src/cgeo/geocaching/utils/CryptUtils.java @@ -46,16 +46,14 @@ public final class CryptUtils { boolean plaintext = false; final int length = text.length(); - int c; - int capitalized; for (int index = 0; index < length; index++) { - c = text.charAt(index); + int c = text.charAt(index); if (c == '[') { plaintext = true; } else if (c == ']') { plaintext = false; } else if (!plaintext) { - capitalized = c & 32; + int capitalized = c & 32; c &= ~capitalized; c = ((c >= 'A') && (c <= 'Z') ? ((c - 'A' + 13) % 26 + 'A') : c) | capitalized; @@ -73,7 +71,7 @@ public final class CryptUtils { digest.update(text.getBytes(), 0, text.length()); hashed = new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { - Log.e("cgBase.md5: " + e.toString()); + Log.e("cgBase.md5", e); } return hashed; @@ -87,7 +85,7 @@ public final class CryptUtils { digest.update(text.getBytes(), 0, text.length()); hashed = new BigInteger(1, digest.digest()).toString(16); } catch (Exception e) { - Log.e("cgBase.sha1: " + e.toString()); + Log.e("cgBase.sha1", e); } return hashed; @@ -102,7 +100,7 @@ public final class CryptUtils { mac.init(secretKeySpec); macBytes = mac.doFinal(text.getBytes()); } catch (Exception e) { - Log.e("cgBase.hashHmac: " + e.toString()); + Log.e("cgBase.hashHmac", e); } return macBytes; @@ -116,16 +114,14 @@ public final class CryptUtils { boolean plaintext = false; final int length = span.length(); - int c; - int capitalized; for (int index = 0; index < length; index++) { - c = span.charAt(index); + int c = span.charAt(index); if (c == '[') { plaintext = true; } else if (c == ']') { plaintext = false; } else if (!plaintext) { - capitalized = c & 32; + int capitalized = c & 32; c &= ~capitalized; c = ((c >= 'A') && (c <= 'Z') ? ((c - 'A' + 13) % 26 + 'A') : c) | capitalized; |
