shell文件:
#!/bin/sh
JAR_PATH="$JBOSS_HOME/server/default/lib/bus-encryption.jar:$JBOSS_HOME/server/default/lib/bmp-jboss-secure.jar"
JAVA="$JAVA_HOME/bin/java"
ENCRYPT_CLASS="com.huawei.bus.commons.encryption.EncryptTool"
QUERY_FLAG="false"
#$JAVA -cp -Xdebug -Xrunjdwp:transport=dt_socket,address=57878,server=y,suspend=y $JAR_PATH $ENCRYPT_CLASS $@
$JAVA -cp $JAR_PATH $ENCRYPT_CLASS $@
--------
入口类在bus-encryption.jar中;
EncryptTool.java文件main():
public static void main(String args[])
{
if (null == args || args.length <= 1 || args[0].equals("-help"))
{
printHelp();
return;
}
if (args.length > 2)
{
System.out.println("usage: bus_encrypt.sh MD5 parameter or bus_encrypt.sh AES parameter");
return;
}
List options = Arrays.asList(args);
String encryptAlgorithm = "AES";
EncryptTool tool = new EncryptTool();
try
{
//AES加密;
if (args.length == 2 && args[0].equalsIgnoreCase("AES"))
{
System.out.println(tool.encrypt(args[1], encryptAlgorithm));
} //MD5加密;
else if (args.length == 2 && args[0].equalsIgnoreCase("MD5"))
{
System.out.println(tool.md5Encrypt(args[1]));
}
}
catch (Exception e)
{
System.out.println("Error occured durring encrypting: " + e);
}
}