Created
September 14, 2011 11:38
-
-
Save falms/1216368 to your computer and use it in GitHub Desktop.
(3) Android
This file contains 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
import java.security.MessageDigest; | |
import java.io.UnsupportedEncodingException; | |
import java.security.NoSuchAlgorithmException; | |
class android{ | |
private static final char[] keys = { '2', '4', '3', '5', '7', '0', 'B', 'E', 'D', '1', 'C', '6', '9', '8', 'F', 'A' }; | |
private static String getPass(String mailaddr, String passcode){ | |
mailaddr = mailaddr.trim(); | |
passcode = passcode.trim(); | |
String result=""; | |
try{ | |
MessageDigest md = MessageDigest.getInstance("SHA-1"); | |
byte[] cbytes = md.digest((mailaddr + passcode).getBytes("8859_1")); | |
StringBuilder ptext = new StringBuilder(); | |
int i = 0; | |
while (true){ | |
if (i >= 10){ | |
result = ptext.toString(); | |
break; | |
} | |
int n = cbytes[i] ^ cbytes[i + 10]; | |
ptext.append(keys[n >> 4 & 0xF]); | |
ptext.append(keys[n & 0xF]); | |
if (i % 2 == 1) ptext.append(' '); | |
i += 1; | |
} | |
}catch (UnsupportedEncodingException localUnsupportedEncodingException){ | |
}catch (NoSuchAlgorithmException localNoSuchAlgorithmException){ | |
} | |
return result; | |
} | |
public static void main( String [] args ){ | |
System.out.println(getPass(args[0], args[1])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment