This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TracksDataUtil { | |
private static String[] bandNames = { | |
"Protest The Hero", | |
"The Fall Of Troy", | |
"Erra", | |
"Periphery", | |
"Napoleon",public class TracksDataUtil { | |
private static String[] bandNames = { | |
"Protest The Hero", | |
"The Fall Of Troy", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Track { | |
private String artist; | |
private String title; | |
private boolean isLiked; | |
private boolean isPlaying; | |
public Track(String artist, String title) { | |
this.artist = artist; | |
this.title = title; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onAuthenticationError(int errorCode, CharSequence errString) { | |
super.onAuthenticationError(errorCode, errString); | |
} | |
@Override | |
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { | |
super.onAuthenticationSucceeded(result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String decryptString(String string, Cipher cipher) { | |
try { | |
byte[] bytes = Base64.decode(string, Base64.NO_WRAP); | |
return new String(cipher.doFinal(bytes)); | |
} catch (IllegalBlockSizeException | BadPaddingException exception) { | |
exception.printStackTrace(); | |
} | |
return null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String encryptString(String string) { | |
try { | |
if (initKeyStore() && initCipher() && initKey() && initCipherMode(Cipher.ENCRYPT_MODE)) { | |
byte[] bytes = sCipher.doFinal(string.getBytes()); | |
return Base64.encodeToString(bytes, Base64.NO_WRAP); | |
} | |
} catch (IllegalBlockSizeException | BadPaddingException e) { | |
e.printStackTrace(); | |
} | |
return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean initCipherMode(int mode) { | |
try { | |
sKeyStore.load(null); | |
switch (mode) { | |
case Cipher.ENCRYPT_MODE: | |
PublicKey key = sKeyStore.getCertificate(KEY_ALIAS).getPublicKey(); | |
PublicKey unrestricted = KeyFactory.getInstance(key.getAlgorithm()).generatePublic(new X509EncodedKeySpec(key.getEncoded())); | |
OAEPParameterSpec spec = new OAEPParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA1, PSource.PSpecified.DEFAULT); | |
sCipher.init(mode, unrestricted, spec); | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean initCipherMode(int mode) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sCipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
sKeyPairGenerator.initialize(new KeyGenParameterSpec.Builder(KEY_ALIAS, | |
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT) | |
.setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA512) | |
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_OAEP) | |
.setUserAuthenticationRequired(true) | |
.build()); | |
sKeyPairGenerator.generateKeyPair(); | |
return true; | |
} catch (InvalidAlgorithmParameterException e) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sKeyPairGenerator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, KEY_STORE); |
NewerOlder