NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.administrator.myapplication;

import android.content.Intent;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MainActivity extends AppCompatActivity {

int progress = 0;
private final static String salt = "DGE$5SGr@3VsHYUMas2323E4d57vfBfFSTRU@!DSH(*%FDSdfg13sgfsg";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


final Button button = findViewById(R.id.button);
final EditText editText = findViewById(R.id.editText);
final EditText editText2 = findViewById(R.id.editText2);

final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.progressBar);



button.setOnClickListener(new View.OnClickListener() {


@Override
public void onClick(View v) {

String username="adm";
String password="123";

String getuser=editText.getText().toString();
String getpass=editText2.getText().toString();

simpleProgressBar.setProgress(progress);
//thread is used to change the progress value



if(username.equals(getuser) & password.equals(getpass)){
//untuk paparan uname & upass betul
//Toast.makeText(getApplicationContext(),"Welcome to LPPSA android version", Toast.LENGTH_SHORT).show();



new Thread(new Runnable() {
@Override
public void run() {
while (progress < 100){
progress += 75;
//update the progress bar and display the current view value in the text view

simpleProgressBar.setProgress(progress);
try{
//sleep for 200 milisecond.
Thread.sleep(1000);
}catch (InterruptedException e){
e.printStackTrace();
}

}
}
}).start();


String detailarray = ("Login username :" + getuser + "/" + "password :" + md5Hash(getpass));
writeToFile(detailarray);
//untuk ke page seterusnya
startActivity(new Intent(MainActivity.this, Main2Activity.class));

}else {
Toast.makeText(getApplicationContext(), "Invalid Username Or Password", Toast.LENGTH_LONG).show();
}
}
});
}

public static String md5Hash(String message){
String md5 = "";
if (null == message)
return null;

//adding a salt to the string before it gets hashed.
message = message+salt;
try{
MessageDigest digest = MessageDigest.getInstance("MD5"); // create messagedigest object for MD5
digest.update(message.getBytes(), 0, message.length()); // update input string in message digest
md5 = new BigInteger(1, digest.digest()).toString(16); // converts message digest value in base 16(hex)
}catch (NoSuchAlgorithmException e){
e.printStackTrace();
}return md5;
}


private void writeToFile(String detailarray) {
try {

BufferedWriter fos = new BufferedWriter(new FileWriter(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+"details.txt"));
fos.write(detailarray);
fos.close();
}
catch(IOException e) {
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.