There is a class in the first activity (SHAsalt) that solo and hash the password:
public class SHAsalt { public static void main2(String[] args) throws NoSuchAlgorithmException { String passwordToHash = "password"; byte[] salt = getSalt(); String securePassword = get_SHA_512_SecurePassword(passwordToHash, salt); System.out.println(securePassword); } private static String get_SHA_512_SecurePassword(String passwordToHash, byte[] salt) { String generatedPassword = null; try { MessageDigest md = MessageDigest.getInstance("SHA-512"); md.update(salt); byte[] bytes = md.digest(passwordToHash.getBytes()); StringBuilder sb = new StringBuilder(); for(int i=0; i< bytes.length ;i++) { sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); } generatedPassword = sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return generatedPassword; } //Add salt private static byte[] getSalt() throws NoSuchAlgorithmException { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); byte[] salt = new byte[16]; sr.nextBytes(salt); return salt; } } Trying to call a method in another class of another activity (login) to get the result "securePassword":
public class LoginActivity extends Activity { public EditText login; public EditText pass; private ProgressDialog dialog; private InputStream is; Main url; TextView textView3; String random; String random2; PasswordGenerator simgen; SHAsalt shasalt; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btn = (Button) findViewById(R.id.button1); login = (EditText) findViewById(R.id.editText1); pass = (EditText) findViewById(R.id.editText2); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { textView3 = (TextView) findViewById(R.id.textView3); /* //ΠΠ΅Π½Π΅ΡΠΈΡΡΠ΅ΠΌ ΡΠΈΠΌΠ²ΠΎΠ»Ρ ΠΈΠ· ΠΊΠ»Π°ΡΡΠ° PasswordGenerator new PasswordGenerator(); //Π²ΡΠ·ΡΠ²Π°Π΅ΠΌ ΡΡΠ½ΠΊΡΠΈΡ Π³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ (488 - 488) Π΄ΠΈΠ°ΠΏΠ°Π·ΠΎΠ½ Π΄Π»ΠΈΠ½Π½Ρ ΠΏΠ°ΡΠΎΠ»Ρ random = simgen.generate(488,488); //ΠΡΠ²ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½ textView3.setText("Random = "+random); */ new SHAsalt(); random2 = shasalt.main2(); //ΠΡΠ²ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½ textView3.setText("Random = "+random2); } Problem: underlines red () in the string "random = shasolt.main2 ();" and highlights
main2 (string []) in SHAsalt cannot be applied to ()
How do I get the value of "securePassword"?