Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Romanian language #39

Merged
merged 11 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Deploy/WultraPassphraseMeter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ Pod::Spec.new do |s|
sub.dependency 'WultraPassphraseMeter/Core'
end

s.subspec 'Dictionary_ro' do |sub|
sub.resources = 'dictionaries/ro.dct'
sub.source_files = 'Source/src_ios/PasswordTester_ro.swift'
sub.dependency 'WultraPassphraseMeter/Core'
end

end
2 changes: 1 addition & 1 deletion Source/examples/Android/PassMeterExample/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
Expand Down Expand Up @@ -34,6 +33,7 @@ dependencies {
implementation "com.wultra.android.passphrasemeter:passphrasemeter-core:${wultraPassphraseMeterVersion}"
implementation "com.wultra.android.passphrasemeter:passphrasemeter-dictionary-en:${wultraPassphraseMeterVersion}"
implementation "com.wultra.android.passphrasemeter:passphrasemeter-dictionary-czsk:${wultraPassphraseMeterVersion}"
implementation "com.wultra.android.passphrasemeter:passphrasemeter-dictionary-ro:${wultraPassphraseMeterVersion}"

implementation 'com.wultra.android.sslpinning:wultra-ssl-pinning:0.9.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,83 @@ package com.wultra.passmeterexample

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.annotation.WorkerThread
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.EditText
import android.widget.TextView
import com.wultra.android.passphrasemeter.*;
import com.wultra.android.passphrasemeter.exceptions.*;
import android.widget.*
import com.wultra.android.passphrasemeter.*
import com.wultra.android.passphrasemeter.exceptions.*

class MainActivity : AppCompatActivity() {

private lateinit var input: EditText
private lateinit var passStrength: TextView
private lateinit var pinIssues: TextView
private lateinit var warningText: TextView
private val input: EditText by lazy { findViewById(R.id.input) }
private val passStrength: TextView by lazy { findViewById(R.id.strengthText) }
private val pinIssues: TextView by lazy { findViewById(R.id.issuesText) }
private val warningText: TextView by lazy { findViewById(R.id.warning) }
private val dropdown: Spinner by lazy { findViewById(R.id.dropdown) }

private val languages = arrayOf(
Language("English", "en.dct"),
Language("Czech & Slovak", "czsk.dct"),
Language("Romanian", "ro.dct")
)

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

input = findViewById(R.id.input)
passStrength = findViewById(R.id.strengthText)
pinIssues = findViewById(R.id.issuesText)
warningText = findViewById(R.id.warning)

PasswordTester.getInstance().loadDictionary(assets, "en.dct")

processText("")

input.addTextChangedListener(object: TextWatcher {
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {

}

override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {

}

override fun afterTextChanged(s: Editable) {
processText(s.toString())
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { }
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { }
})

dropdown.adapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, languages)
dropdown.onItemSelectedListener = object: AdapterView.OnItemSelectedListener {
override fun onItemSelected(adapter: AdapterView<*>?, view: View?, position: Int, id: Long) {
prepareLanguage(languages[position])
}

override fun onNothingSelected(p0: AdapterView<*>?) { }
}
dropdown.setSelection(0) // select first item
}

@WorkerThread
private fun prepareLanguage(language: Language) {
if (PasswordTester.getInstance().hasLoadedDictionary()) {
PasswordTester.getInstance().freeLoadedDictionary()
}
PasswordTester.getInstance().loadDictionary(assets, language.dictionaryAsset)
input.setText("")
}

private fun processText(text: String) {
processPasssword(text)
processPassword(text)
processPin(text)
}

private fun processPasssword(password: String) {
private fun processPassword(password: String) {

var text: String
val text: String

if (password.isNotEmpty()) {

try {

val result = PasswordTester.getInstance().testPassword(password)
text = try {

when (result) {
PasswordStrength.STRONG -> text = "Strong 💪"
PasswordStrength.GOOD -> text = "Good 👍"
PasswordStrength.MODERATE -> text = "Moderate 🤔"
PasswordStrength.WEAK -> text = "Weak 🙄"
PasswordStrength.VERY_WEAK -> text = "Very Weak 🤦‍"
when (PasswordTester.getInstance().testPassword(password)) {
PasswordStrength.STRONG -> "Strong 💪"
PasswordStrength.GOOD -> "Good 👍"
PasswordStrength.MODERATE -> "Moderate 🤔"
PasswordStrength.WEAK -> "Weak 🙄"
PasswordStrength.VERY_WEAK, null -> "Very Weak 🤦‍"
}
} catch (e: WrongPasswordException) {
text = "Password format exception"
"Password format exception"
}

} else {
Expand Down Expand Up @@ -110,12 +119,12 @@ class MainActivity : AppCompatActivity() {
}
}

if (pin.length == 4) {
warnUser = result.contains(PinTestResult.FREQUENTLY_USED) || result.contains(PinTestResult.NOT_UNIQUE)
warnUser = if (pin.length == 4) {
result.contains(PinTestResult.FREQUENTLY_USED) || result.contains(PinTestResult.NOT_UNIQUE)
} else if (pin.length <= 6) {
warnUser = result.contains(PinTestResult.FREQUENTLY_USED) || result.contains(PinTestResult.NOT_UNIQUE) || result.contains(PinTestResult.REPEATING_CHARACTERS)
result.contains(PinTestResult.FREQUENTLY_USED) || result.contains(PinTestResult.NOT_UNIQUE) || result.contains(PinTestResult.REPEATING_CHARACTERS)
} else {
warnUser = result.contains(PinTestResult.FREQUENTLY_USED) || result.contains(PinTestResult.NOT_UNIQUE) || result.contains(PinTestResult.REPEATING_CHARACTERS) || result.contains(PinTestResult.HAS_PATTERN)
result.contains(PinTestResult.FREQUENTLY_USED) || result.contains(PinTestResult.NOT_UNIQUE) || result.contains(PinTestResult.REPEATING_CHARACTERS) || result.contains(PinTestResult.HAS_PATTERN)
}

} catch (e: WrongPinException) {
Expand All @@ -130,6 +139,12 @@ class MainActivity : AppCompatActivity() {
}

private fun isPin(text: String): Boolean {
return text.isEmpty() == false && text.all { "0987654321".contains(it) }
return text.isNotEmpty() && text.all { "0987654321".contains(it) }
}

data class Language(val name: String, val dictionaryAsset: String) {
override fun toString(): String {
return name
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,92 @@
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WULTRA PASSPHRASE TESTER"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="16dp"
app:layout_constraintVertical_bias="0.0" android:textSize="24sp" android:textStyle="bold"
android:layout_marginRight="16dp" android:layout_marginLeft="16dp" android:id="@+id/title"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WULTRA PASSPHRASE TESTER"
android:id="@+id/title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintVertical_bias="0.0"
android:textSize="24sp"
android:textStyle="bold" />

<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dropdown"
android:layout_marginTop="36dp"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/prompt"
app:layout_constraintEnd_toEndOf="parent" />

<TextView
android:text="Type password or pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/prompt" android:layout_marginTop="37dp"
app:layout_constraintTop_toBottomOf="@+id/title" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="162dp" android:layout_marginBottom="11dp"
app:layout_constraintBottom_toTopOf="@+id/input" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="164dp" app:layout_constraintHorizontal_bias="0.49"/>
android:text="Type password or pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/prompt"
android:layout_marginTop="12dp"
app:layout_constraintTop_toBottomOf="@+id/dropdown"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/input"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/input" android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/prompt" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="32dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="32dp" android:layout_marginBottom="13dp"
app:layout_constraintBottom_toTopOf="@+id/textView2" android:textAlignment="center"
/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:id="@+id/input"
android:textAlignment="center"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/prompt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/textView2" />
<TextView
android:text="Password strength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:textStyle="bold"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/input"
app:layout_constraintStart_toStartOf="@+id/input"/>
android:text="Password strength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:textStyle="bold"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="@+id/input"
app:layout_constraintStart_toStartOf="@+id/input" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/strengthText" app:layout_constraintStart_toStartOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/textView2" android:layout_marginTop="8dp"/>
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/strengthText"
app:layout_constraintStart_toStartOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/textView2"
android:layout_marginTop="8dp"/>
<TextView
android:text="PIN issues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView4" app:layout_constraintStart_toStartOf="@+id/strengthText"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/strengthText" android:textStyle="bold"/>
android:text="PIN issues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_marginTop="16dp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@+id/strengthText"
app:layout_constraintTop_toBottomOf="@+id/strengthText" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/issuesText" app:layout_constraintStart_toStartOf="@+id/textView4"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView4"/>
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/issuesText"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="@+id/textView4"
app:layout_constraintTop_toBottomOf="@+id/textView4"/>
<TextView
android:text="Consider using different pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/warning" app:layout_constraintStart_toStartOf="@+id/issuesText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/issuesText" android:textColor="@android:color/holo_orange_dark"/>
android:text="Consider using different pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/warning"
android:textColor="@android:color/holo_orange_dark"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="@+id/issuesText"
app:layout_constraintTop_toBottomOf="@+id/issuesText" />

</android.support.constraint.ConstraintLayout>
10 changes: 3 additions & 7 deletions Source/examples/Android/PassMeterExample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

ext {
wultraPassphraseMeterVersion = "1.0.0"
wultraPassphraseMeterVersion = "1.1.0-SNAPSHOT"
}

allprojects {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -177,7 +177,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1010;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1340;
ORGANIZATIONNAME = "Wultra s.r.o.";
TargetAttributes = {
DC0C4D6D221D5D690058963D = {
Expand Down Expand Up @@ -383,6 +383,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -444,6 +445,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
Loading