Password Strength is an Android Library that checks for a password strength.
For information on how to get started with Password Strength, take a look at our Getting Started guide.
Bugs or feature requests should be submitted at our GitHub Issues section.
Password Strength for Android is available through Google's Maven Repository. To use it:
-
Open the
build.gradle
file for your application. -
Make sure that the
repositories
section includes Google's Maven Repositorygoogle()
. For example:allprojects { repositories { google() jcenter() } }
-
Add the library to the
dependencies
section:dependencies { // ... implementation 'com.zeoflow:password-strength:<version>' // ... }
MainActivity.java
public class MainActivity extends BindAppActivity<ActivityMainBinding, MainViewBinding>
{
//..
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
//..
// Create a map of excluded words on a per-user basis using a hypothetical "User" object that contains this info
List<Dictionary> dictionaryList = ConfigurationBuilder.getDefaultDictionaries(this);
dictionaryList.add(new DictionaryBuilder(this)
.setDictionaryName("exclude")
.setExclusion(true)
.addWord("word", 0)
.createDictionary());
// Create our configuration object and set our custom minimum
// entropy, and custom dictionary list
Configuration configuration = new ConfigurationBuilder()
.setMinimumEntropy(40d)
.setDictionaries(dictionaryList)
.createConfiguration(this);
// Create our PasswordChecker object with the configuration we built
PasswordChecker passwordChecker = new PasswordChecker(configuration);
// passwordStrength is of PasswordType type
// PasswordType can be (VERY_WEAK, WEAK, MEDIUM, STRONG, VERY_STRONG)
PasswordType passwordStrength = passwordChecker.estimate("asdasdssd").getStrength();
//..
}
//..
}
Copyright 2020 ZeoFlow
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.