List of utility methods to do Password Encrypt
String | encrypt(String password, String data) encrypt byte[] secretKey = generateKey(password.getBytes()); byte[] clear = data.getBytes(); SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey, CIPHER_ALGORITHM); Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); byte[] encrypted = cipher.doFinal(clear); String encryptedString = Base64.encodeToString(encrypted, ... |
String | encryptionKey(String password) encryption Key byte[] keyByte1 = key1.getBytes(); byte[] keyByte2 = key2.getBytes(); byte[] pwdByte = password.getBytes(); for (int i = 0; i < pwdByte.length; i++) { pwdByte[i] = (byte) (pwdByte[i] ^ keyByte1[i % keyByte1.length]); byte[] countByte = new byte[pwdByte.length + keyByte1.length]; for (int i = 0; i < countByte.length; i++) { ... |
String | encryptionKey(String password) encryption Key byte[] keyByte1 = key1.getBytes(); byte[] keyByte2 = key2.getBytes(); byte[] pwdByte = password.getBytes(); for (int i = 0; i < pwdByte.length; i++) { pwdByte[i] = (byte) (pwdByte[i] ^ keyByte1[i % keyByte1.length]); byte[] countByte = new byte[pwdByte.length + keyByte1.length]; for (int i = 0; i < countByte.length; i++) { ... |