Java
Java
Workaround for the deprecated Crypt2.HashString method
Shows how to replace the deprecated HashString method. (Chilkat is moving away from the use of CkByteData.)Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
CkCrypt2 crypt = new CkCrypt2();
crypt.put_Charset("utf-8");
crypt.put_HashAlgorithm("sha256");
String inputStr = "This is a test.";
// ------------------------------------------------------------------------
// The HashString method is deprecated:
CkByteData outData = new CkByteData();
success = crypt.HashString(inputStr,outData);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData)
crypt.put_EncodingMode("base64");
String hash_base64 = crypt.hashStringENC(inputStr);
System.out.println(hash_base64);
}
}