Skip to content

Commit

Permalink
上传第一版
Browse files Browse the repository at this point in the history
  • Loading branch information
takurom committed Feb 22, 2020
1 parent 7435884 commit 8d5a5d4
Show file tree
Hide file tree
Showing 46 changed files with 1,434 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "top.takuron.seekpassword"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.android.material:material:1.0.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package top.takuron.seekpassword;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("top.takuron.seekpassword", appContext.getPackageName());
}
}
23 changes: 23 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="top.takuron.seekpassword">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".view.PasswordActivity"
android:label="@string/title_password_activity"></activity>
<activity android:name=".view.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
27 changes: 27 additions & 0 deletions app/src/main/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="js/md5.min.js"></script>
<script type="text/javascript" src="src/seek_password.js"></script>
<title>Wsine - 觅密</title>
</head>
<body>
<h1>Test</h1>
<script type="text/javascript">

function calljs(pwd,key,checked){
var sk_pwd = generate_password(pwd,key);
if (sk_pwd) {

if (checked) {
return sk_pwd.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]\+]/g, "");
} else {
return sk_pwd;
}
}
}
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions app/src/main/assets/js/md5.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions app/src/main/assets/src/seek_password.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// refer from https://flowerpassword.com
function flower_password(pwd, key) {
var md5one = md5(pwd, key);
var md5two = md5(md5one, "snow");
var md5three = md5(md5one, "kise");
// to uppercase
var rule = md5three.split("");
var source = md5two.split("");
console.assert(rule.length === source.length, "md5 output length not equal");
for (var i = 0; i < source.length; ++i) {
if (isNaN(source[i])) {
var str = "sunlovesnow1990090127xykab";
if (str.search(rule[i]) > -1) {
source[i] = source[i].toUpperCase();
}
}
}
var code32 = source.join("");
var code1 = code32.slice(0, 1);
if (isNaN(code1)) {
var code16 = code32.slice(0, 16);
} else {
var code16 = "K" + code32.slice(1, 16);
}
return [code16, code32];
}

function seek_password(hash) {
// generate alphabet
var lower = "abcdefghijklmnopqrstuvwxyz".split("");
var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
var number = "0123456789".split("");
var punctuation = ",.:;!?".split("");
var alphabet = lower.concat(upper).concat(number).concat(punctuation);
// try to generate password
for (var i = 0; i <= hash.length - 10; ++i) {
var sub_hash = hash.slice(i, i + 10).split("");
var count = 0;
var map_index = sub_hash.map(function(c) {
count = (count + c.charCodeAt()) % alphabet.length;
return count;
});
var sk_pwd = map_index.map(function(k) { return alphabet[k]; });
// validate password
var matched = [false, false, false, false];
sk_pwd.forEach(function(e) {
matched[0] = matched[0] || lower.includes(e);
matched[1] = matched[1] || upper.includes(e);
matched[2] = matched[2] || number.includes(e);
matched[3] = matched[3] || punctuation.includes(e);
});
if (!matched.includes(false)) {
return sk_pwd.join("");
}
}
return "";
}

function generate_password(pwd, key) {
if (pwd && key) {
var fl_pwd = flower_password(pwd, key);
var hash = fl_pwd[1];
console.assert(hash.length === 32, "flower_password output length not equal to 32");
var sk_pwd = seek_password(hash);
return sk_pwd;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package top.takuron.seekpassword.presenter;

import android.content.Context;
import android.webkit.ValueCallback;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;

public class MainPresenter {
public static void seekpassword(LinearLayout father, final String password , final String code, final boolean checked, final OnSeekpasswordlinstener is){
WebView wv = new WebView(father.getContext());
WebSettings settings = wv.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setBlockNetworkImage(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);

wv.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
view.evaluateJavascript("javascript:calljs('"+password+"','"+code+"',"+checked+")",
new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
is.onReturn(s.replace("\"",""));
}
});
}
});



father.addView(wv);
wv.loadUrl("file:///android_asset/index.html");


}

}
Loading

0 comments on commit 8d5a5d4

Please sign in to comment.