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:
24
src/org/kde/kdeconnect/Helpers/RandomHelper.java
Normal file
24
src/org/kde/kdeconnect/Helpers/RandomHelper.java
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -39,6 +39,7 @@ import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
|
|||||||
import org.apache.sshd.server.session.ServerSession;
|
import org.apache.sshd.server.session.ServerSession;
|
||||||
import org.apache.sshd.server.sftp.SftpSubsystem;
|
import org.apache.sshd.server.sftp.SftpSubsystem;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
|
import org.kde.kdeconnect.Helpers.RandomHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
@@ -123,7 +124,8 @@ class SimpleSftpServer {
|
|||||||
|
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
String password = Long.toHexString(Double.doubleToLongBits(Math.random()));
|
|
||||||
|
String password = RandomHelper.randomString(28);
|
||||||
passwordAuth.setPassword(password);
|
passwordAuth.setPassword(password);
|
||||||
|
|
||||||
port = STARTPORT;
|
port = STARTPORT;
|
||||||
|
Reference in New Issue
Block a user