instrument: finish symmetric text encryption test

This commit is contained in:
Vincent Breitmoser
2015-06-15 17:54:53 +02:00
parent 312cb38848
commit 2d03965777
4 changed files with 156 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
package org.sufficientlysecure.keychain;
import java.util.Random;
import android.content.Context;
import android.support.annotation.StringRes;
@@ -52,4 +54,16 @@ public class TestHelpers {
}
public static String randomString(int min, int max) {
String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789!@#$%^&*()-_=";
Random r = new Random();
StringBuilder passbuilder = new StringBuilder();
// 5% chance for an empty string
for(int i = 0, j = r.nextInt(max)+min; i < j; i++) {
passbuilder.append(chars.charAt(r.nextInt(chars.length())));
}
return passbuilder.toString();
}
}