I know this sounds like a broad question, but I can narrow it down with an example. I am VERY new in Java. For one of my training projects, I wanted to create my own MD5 hash file for use by us. I started very simply, trying to hash the string, and then go to the file later. I created the MD5Hasher.java file and wrote the following:
import java.security.*;
import java.io.*;
public class MD5Hasher{
public static void main(String[] args){
String myString = "Hello, World!";
byte[] myBA = myString.getBytes();
MessageDigest myMD;
try{
myMD = MessageDigest.getInstance("MD5");
myMD.update(myBA);
byte[] newBA = myMD.digest();
String output = newBA.toString();
System.out.println("The Answer Is: " + output);
} catch(NoSuchAlgorithmException nsae){
}
}
}
java.sun.com, javadocs java.security, , MessageDigest. , getInstance MessageDigest, . Javadoc : " ". , , , . : " , , , ". , , . "toString" , , . , , , , :
: [B @4cb162d5
StackOverflow :
MD5?
:
String plaintext = 'your text here';
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(plaintext.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16);
while(hashtext.length() < 32 ){
hashtext = "0"+hashtext;
}
, , , "BigInteger", .
, , , , , "BigInteger"? , toString newBA , , -, . , Java? C, Java- . , , "" Googling, - ?
, .: -)