Android Open Source - SmartPass Password Lib






From Project

Back to project page SmartPass.

License

The source code is released under:

Copyright (c) 2013 Dax Earl, Aaron Golliver Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal ...

If you think the Android project SmartPass listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.passwordLib;
/*from ww w .ja  va2s. c  o m*/
import android.annotation.SuppressLint;

@SuppressLint("DefaultLocale")
public class PasswordLib {

  final static private String lowercase = "abcdefghijklmnopqrstuvwxyz";

  final static private String uppercase = "abcdefghijklmnopqrstuvwxyz"
      .toUpperCase();
  final static private String numbers = "0123456789";
  final static private String specialCharacters = "!@#$%^&*()_+-=[]{};':\",./<>?\\|";

  public static String createPassword(int maxLength, boolean lower,
      boolean upper, boolean number, boolean special) {
    String possibleChars = "";
    if (lower)
      possibleChars += lowercase;
    if (upper)
      possibleChars += uppercase;
    if (number)
      possibleChars += numbers;
    if (special)
      possibleChars += specialCharacters;

    char[] possibleCharsArray = possibleChars.toCharArray();

    char password[] = new char[maxLength];

    for (int i = 0; i < maxLength; i++) {
      int rand = (int) (Math.random() * possibleCharsArray.length);
      password[i] = possibleCharsArray[rand];
    }

    return String.valueOf(password);
  }

  /*
   * public static String createEncryptedPassword(int maxLength, boolean
   * lower, boolean upper, boolean number, boolean special, String
   * masterPassword) { try { return SimpleCrypto.encrypt(masterPassword,
   * createPassword(maxLength, lower, upper, number, special)); } catch
   * (InvalidKeyException e) { e.printStackTrace(); } catch
   * (NoSuchAlgorithmException e) { e.printStackTrace(); } catch
   * (NoSuchPaddingException e) { e.printStackTrace(); } catch
   * (IllegalBlockSizeException e) { e.printStackTrace(); } catch
   * (BadPaddingException e) { e.printStackTrace(); } return null; }
   */

  public static String encrypt(String input, String masterPassword) {
    try {
      return SimpleCrypto.encrypt(input, masterPassword);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return null;
  }

  public static String decode(String encryptedString, String masterPassword) {
    try {
      return SimpleCrypto.decrypt(encryptedString,
          masterPassword);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return null;
  }
}




Java Source Code List

com.example.smartpass.ClearClipboard.java
com.example.smartpass.CopyPasswordToClipboard.java
com.example.smartpass.CopyUsernameToClipboard.java
com.example.smartpass.DeletePassword.java
com.example.smartpass.LoginScreen.java
com.example.smartpass.NewAccount.java
com.example.smartpass.NewFolder.java
com.example.smartpass.PasswordList.java
com.example.smartpass.UserAccount.java
com.example.smartpass.Adapter.NothingSelectedSpinnerAdapter.java
com.example.smartpass.Adapter.PasswordListAdapter.java
com.example.smartpass.Classes.ExpandListChild.java
com.example.smartpass.Classes.ExpandListGroup.java
com.passwordLib.Main.java
com.passwordLib.PasswordFile.java
com.passwordLib.PasswordLib.java
com.passwordLib.RetrivePasswordTask.java
com.passwordLib.SendPasswordTask.java
com.passwordLib.SimpleCrypto.java