· 6 years ago · Feb 05, 2019, 02:56 PM
1$textToEncrypt = $_GET['login'];
2$secretHash = $_GET['key'];
3$encryptionMethod = "AES";
4$iv = "1234567891234567";
5$encryptedMessage = openssl_encrypt($textToEncrypt, $encryptionMethod, $secretHash,0, $iv );
6$data = base64_encode ($iv.$encryptedMessage);
7echo $data;
8
9
10IvParameterSpec iv = new IvParameterSpec("1234567891234567".getBytes("UTF-8"));
11 //генирируем Ñлучайный ÐЕС ключ
12 Cipher cipher = Cipher.getInstance("AES");
13 byte[] key = ("ytrewq").getBytes("UTF-8");
14 key = Arrays.copyOf(key, 16); // use only first 128 bit
15 SecretKey secretKey = new SecretKeySpec(key,"AES");
16 cipher.init(Cipher.ENCRYPT_MODE,secretKey,iv);
17 byte[] bytes = cipher.doFinal(s.getBytes());
18 String loadCriptLogin = android.util.Base64.encodeToString(bytes, android.util.Base64.DEFAULT);
19System.out.println(loadCriptLogin);
20 TextView textView = (TextView)findViewById(R.id.text);
21 textView.setText(loadCriptLogin);