2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Using longer and mixed case passwords

This commit is contained in:
Albert Vaca 2016-02-17 04:48:01 -08:00
parent 89a65ab3e2
commit 521a27c09d
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,24 @@
package org.kde.kdeconnect.Helpers;
import android.util.Log;
import java.security.SecureRandom;
public class RandomHelper {
public static SecureRandom secureRandom = new SecureRandom();
private static final char[] symbols = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
"abcdefghijklmnopqrstuvwxyz"+
"1234567890").toCharArray();
public static String randomString(int length) {
char[] buffer= new char[length];
for (int idx = 0; idx < length; ++idx) {
buffer[idx] = symbols[secureRandom.nextInt(symbols.length)];
}
return new String(buffer);
}
}

View File

@ -39,6 +39,7 @@ import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.sftp.SftpSubsystem;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.Helpers.RandomHelper;
import java.io.File;
import java.net.Inet4Address;
@ -123,7 +124,8 @@ class SimpleSftpServer {
public boolean start() {
if (!started) {
String password = Long.toHexString(Double.doubleToLongBits(Math.random()));
String password = RandomHelper.randomString(28);
passwordAuth.setPassword(password);
port = STARTPORT;