Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SettingsHolder.SETTINGS.setValue(RememberCredentials.class, true);
- String key = TextUtils.generate(new SecureRandom().nextInt(10 - 6 + 1) + 6, TextUtils.NUMBERS);
- System.out.println(key);
- String salt = TextUtils.generate(16 - key.length(), TextUtils.LETTERS_NUMBERS_SYMBOLS);
- System.out.println(salt);
- SettingsHolder.SETTINGS.setValue(Salt.class, salt);
- Placement place = new SecureRandom().nextInt(2) == 0 ? Placement.BEFORE : Placement.AFTER;
- System.out.println(place.toString());
- SettingsHolder.SETTINGS.setValue(Position.class, place);
- String saltAndKey = place.equals(Placement.BEFORE) ? salt + key : key + salt;
- System.out.println(String.format("%s:%d:%d", saltAndKey, saltAndKey.length(), saltAndKey.getBytes().length));
- String keyHash = StreamHash.getStreamHash(new ByteArrayInputStream(saltAndKey.getBytes()), StreamHash.getDigest("SHA-512"));
- SettingsHolder.SETTINGS.setValue(Hash.class, keyHash);
- System.out.println(keyHash);
- Key secretKey = new StringEncryption(saltAndKey).getKey();
- String encryptedUsername = EncryptionStandard.encrypt("Daniel", secretKey);
- SettingsHolder.SETTINGS.setValue(Username.class, encryptedUsername);
- String encryptedPassword = EncryptionStandard.encrypt("gcnc1gekxztn", secretKey);
- SettingsHolder.SETTINGS.setValue(Password.class, encryptedPassword);
- System.out.println(encryptedUsername);
- System.out.println(encryptedPassword);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement