diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2014-03-09 12:58:29 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2014-03-09 12:58:29 +0100 |
commit | 91130612d4351cf79b4d357a8c6b08659de59cd7 (patch) | |
tree | ce334fafa3bc86fdc1f7a12933533b07be14a5a0 /src/eu/siacs/conversations/utils | |
parent | d543d377b713db99aab1f03f5e45c8b46b4b4fa0 (diff) |
cleanup
Diffstat (limited to 'src/eu/siacs/conversations/utils')
-rw-r--r-- | src/eu/siacs/conversations/utils/CryptoHelper.java | 20 | ||||
-rw-r--r-- | src/eu/siacs/conversations/utils/SASL.java | 24 |
2 files changed, 20 insertions, 24 deletions
diff --git a/src/eu/siacs/conversations/utils/CryptoHelper.java b/src/eu/siacs/conversations/utils/CryptoHelper.java index 6e606fa10..ebbbd9674 100644 --- a/src/eu/siacs/conversations/utils/CryptoHelper.java +++ b/src/eu/siacs/conversations/utils/CryptoHelper.java @@ -1,5 +1,7 @@ package eu.siacs.conversations.utils; +import android.util.Base64; + public class CryptoHelper { final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); public static String bytesToHex(byte[] bytes) { @@ -11,4 +13,22 @@ public class CryptoHelper { } return new String(hexChars); } + public static String saslPlain(String username, String password) { + byte[] userBytes = username.getBytes(); + int userLenght = userBytes.length; + byte[] passwordBytes = password.getBytes(); + byte[] saslBytes = new byte[userBytes.length+passwordBytes.length+2]; + saslBytes[0] = 0x0; + for(int i = 1; i < saslBytes.length; ++i) { + if (i<=userLenght) { + saslBytes[i] = userBytes[i-1]; + } else if (i==userLenght+1) { + saslBytes[i] = 0x0; + } else { + saslBytes[i] = passwordBytes[i-(userLenght+2)]; + } + } + + return Base64.encodeToString(saslBytes, Base64.DEFAULT); + } } diff --git a/src/eu/siacs/conversations/utils/SASL.java b/src/eu/siacs/conversations/utils/SASL.java deleted file mode 100644 index cda1f97be..000000000 --- a/src/eu/siacs/conversations/utils/SASL.java +++ /dev/null @@ -1,24 +0,0 @@ -package eu.siacs.conversations.utils; - -import android.util.Base64; - -public class SASL { - public static String plain(String username, String password) { - byte[] userBytes = username.getBytes(); - int userLenght = userBytes.length; - byte[] passwordBytes = password.getBytes(); - byte[] saslBytes = new byte[userBytes.length+passwordBytes.length+2]; - saslBytes[0] = 0x0; - for(int i = 1; i < saslBytes.length; ++i) { - if (i<=userLenght) { - saslBytes[i] = userBytes[i-1]; - } else if (i==userLenght+1) { - saslBytes[i] = 0x0; - } else { - saslBytes[i] = passwordBytes[i-(userLenght+2)]; - } - } - - return Base64.encodeToString(saslBytes, Base64.DEFAULT); - } -} |