This commit is contained in:
Vladimir Krivosheev
2014-08-25 10:05:37 +02:00
parent f0ea331b24
commit ade300c6d4
2 changed files with 11 additions and 4 deletions
@@ -15,13 +15,17 @@
*/
package com.intellij.openapi.util;
import org.jetbrains.annotations.Nullable;
public class PasswordUtil {
private PasswordUtil() { }
// weak encryption just to avoid plain text passwords in text files
public static String encodePassword(String password) {
public static String encodePassword(@Nullable String password) {
String result = "";
if (password == null) return result;
if (password == null) {
return result;
}
for (int i = 0; i < password.length(); i++) {
int c = password.charAt(i);
c ^= 0xdfaa;
@@ -30,9 +34,11 @@ public class PasswordUtil {
return result;
}
public static String decodePassword(String password) throws NumberFormatException {
public static String decodePassword(@Nullable String password) throws NumberFormatException {
String result = "";
if (password == null) return result;
if (password == null) {
return result;
}
for (int i = 0; i < password.length(); i += 4) {
String s = password.substring(i, i + 4);
int c = Integer.parseInt(s, 16);
@@ -69,6 +69,7 @@ public abstract class Logger {
return ourFactory.getLoggerInstance(category);
}
@NotNull
public static Logger getInstance(Class cl) {
return getInstance("#" + cl.getName());
}