コード例 #1
0
  public void btnLoginClick(View v) {
    if (edtPassword.getText().toString().equals("")) {
      showMessage("Error", "You must type password!");
      return;
    }
    // Get shared preferences
    SharedPreferences sharedPref = getSharedPreferences("security", Context.MODE_PRIVATE);

    // Get password user set
    String password = sharedPref.getString("password", null);
    String input = "";
    try {
      // Encript password 128 bit and convert this to string
      input = new String(Encrypt.generateKey(edtPassword.getText().toString()), "UTF8");
    } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    // Check pass user input
    System.out.println(password);
    System.out.println(input);
    if (password.equals(input)) {
      Intent intent = new Intent(this, MainActivity.class);
      startActivity(intent);
    } else {
      showMessage("Error", "Password incorrect!");
    }
  }
コード例 #2
0
  // Get Image by Url
  public Bitmap load(final String uri) {
    if (uri == null) return null;

    final String key = Encrypt.md5(uri);
    Bitmap bmp = getFromCache(key);

    if (bmp != null) return bmp;

    bmp = BitmapFactory.decodeFile(uri);
    addToCache(key, bmp);
    return bmp;
  }
コード例 #3
0
ファイル: MainClass.java プロジェクト: KimBoWoon/HomeWork
  public static void main(String[] args) {
    try {
      // 입력 파일 이름을 입력받는다
      Scanner stdin = new Scanner(System.in);
      System.out.println("Input File Name");
      String fileName = stdin.nextLine();
      // 파일 읽음
      FileRead in = new FileRead(fileName);
      // 출력 파일 이름을 입력받는다
      System.out.println("Output File Name");
      fileName = stdin.nextLine();
      // 파일 기록
      FileWrite out = new FileWrite(fileName);
      // 암호화
      Encrypt encrypt = new Encrypt();
      // 복호화
      Decrypt decrypt = new Decrypt();
      // 암호화된 문자열을 byte 배열에 담는다
      byte[] encryptText;
      // 복호화된 문자열 저장
      String decryptText;

      String plainText = in.fileRead();
      System.out.println("Plain Text : " + plainText);

      // 암호화
      encryptText = encrypt.encrypt(plainText);
      System.out.println("Encrypt Text : " + encryptText);

      out.fileWrite(encryptText);

      // 복호화
      decryptText = decrypt.decrypt(encryptText);
      System.out.println("Decrypt Text : " + decryptText);
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("Main Exception");
    }
  }
コード例 #4
0
 public static void main(String[] args) {
   if (args.length > 0) {
     String command = args[0];
     String[] arguments = new String[args.length - 1];
     System.arraycopy(args, 1, arguments, 0, arguments.length);
     boolean exitAfterCallingMain = true;
     try {
       if (command.equals("ConvertColorspace")) {
         ConvertColorspace.main(arguments);
       } else if (command.equals("Decrypt")) {
         Decrypt.main(arguments);
       } else if (command.equals("Encrypt")) {
         Encrypt.main(arguments);
       } else if (command.equals("ExtractText")) {
         ExtractText.main(arguments);
       } else if (command.equals("Overlay")) {
         Overlay.main(arguments);
       } else if (command.equals("PrintPDF")) {
         PrintPDF.main(arguments);
       } else if (command.equals("PDFDebugger")) {
         PDFDebugger.main(arguments);
         exitAfterCallingMain = false;
       } else if (command.equals("PDFMerger")) {
         PDFMerger.main(arguments);
       } else if (command.equals("PDFReader")) {
         PDFReader.main(arguments);
         exitAfterCallingMain = false;
       } else if (command.equals("PDFSplit")) {
         PDFSplit.main(arguments);
       } else if (command.equals("PDFToImage")) {
         PDFToImage.main(arguments);
       } else if (command.equals("TextToPDF")) {
         TextToPDF.main(arguments);
       } else if (command.equals("WriteDecodedDoc")) {
         WriteDecodedDoc.main(arguments);
       } else {
         showMessageAndExit();
       }
       if (exitAfterCallingMain) {
         System.exit(0);
       }
     } catch (Exception e) {
       System.err.println(command + " failed with the following exception:");
       e.printStackTrace();
       System.exit(1);
     }
   } else {
     showMessageAndExit();
   }
 }