java代码翻译

yklnyc 2018-06-05 11:34:42
public class GetAuthorizationCode
{
public static String getWindowsMACAddress()
{
String mac = null;
BufferedReader bufferedReader = null;
Process process = null;
label129:
try
{
process = Runtime.getRuntime().exec("ipconfig /all");
bufferedReader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
String line = null;
int index = -1;
while ((line = bufferedReader.readLine()) != null)
{
index = line.toLowerCase().indexOf("physical address");
if (index >= 0)
{
index = line.indexOf(":");
if (index < 0) {
break;
}
mac = line.substring(index + 1).trim();
break label129;
}
}
}
catch (IOException localIOException1) {}finally
{
try
{
if (bufferedReader != null) {
bufferedReader.close();
}
}
catch (IOException e1)
{
e1.printStackTrace();
}
bufferedReader = null;
process = null;
}
return mac;
}

public static void main(String[] argc)
{
UIManager.put("swing.boldMetal", Boolean.FALSE);
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception localException) {}
String mac = getWindowsMACAddress();
RandomAccessFile rdafile = null;
try
{
rdafile = new RandomAccessFile("authorizationcode.txt", "rw");
mac = StringSecurity.encode(mac, "SHA-1");
mac = StringSecurity.encode(mac, "SHA-256");
rdafile.seek(rdafile.length());
rdafile.writeBytes(mac);
rdafile.seek(rdafile.length());
rdafile.writeBytes("\r\n");
PromptDialog promptdialog = new PromptDialog(new JFrame(), "", true);
promptdialog.setPromptString("", "申请授权成功,请将授权码文件发给作者,等待批准授权!", "", "授权");
promptdialog.setVisible(true);
rdafile.close();
System.exit(0);
}
catch (Exception localException1) {}finally
{
try
{
rdafile.close();
System.exit(0);
}
catch (Exception localException2) {}
}
}
}

public class SetAuthorizationCode
{
public static void main(String[] argc)
{
UIManager.put("swing.boldMetal", Boolean.FALSE);
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception localException) {}
RandomAccessFile rdafileone = null;
RandomAccessFile rdafiletwo = null;
String stroriginaltext = "";
String strsecrettext = "";
try
{
File file = new File("authorizationcode.txt");
if (file.exists())
{
rdafileone = new RandomAccessFile("authorizationcode.txt", "rw");
rdafiletwo = new RandomAccessFile("legalauthorizationcode.key", "rw");
while ((stroriginaltext = rdafileone.readLine()) != null) {
if (!stroriginaltext.equals(""))
{
strsecrettext = StringSecurity.encode(stroriginaltext);
strsecrettext = StringSecurity.encode(strsecrettext);
rdafiletwo.writeBytes(strsecrettext + "\r\n");
}
}
PromptDialog promptdialog = new PromptDialog(new JFrame(), "", true);
promptdialog.setPromptString("", "成功批准授权!", "", "批准授权");
promptdialog.setVisible(true);
rdafileone.close();
rdafiletwo.close();
}
else
{
PromptDialog promptdialog = new PromptDialog(new JFrame(), "", true);
promptdialog.setPromptString("", "批准授权失败!", "", "批准授权");
promptdialog.setVisible(true);
}
System.exit(0);
}
catch (Exception localException1) {}finally
{
try
{
rdafileone.close();
rdafiletwo.close();
System.exit(0);
}
catch (Exception localException2) {}
}
}
}


public class StringSecurity
{
private static final String[] hexDigits = { "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
public static final String MD5 = "MD5";
public static final String SHA1 = "SHA-1";
public static final String SHA256 = "SHA-256";

private static String byteArrayToHexString(byte[] b)
{
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
resultSb.append(byteToHexString(b[i]));
}
return resultSb.toString();
}

private static String byteToHexString(byte b)
{
int n = b;
if (n < 0) {
n += 256;
}
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}

public static String encode(String data)
{
String resultString = null;
try
{
resultString = new String(data);
MessageDigest md = MessageDigest.getInstance("MD5");
resultString = byteArrayToHexString(md.digest(
resultString.getBytes()));
}
catch (Exception ex)
{
ex.printStackTrace();
}
return resultString.toUpperCase();
}

public static String encode(String data, String encType)
{
String resultString = null;
try
{
resultString = new String(data);
MessageDigest md = MessageDigest.getInstance(encType);
resultString = byteArrayToHexString(md.digest(
resultString.getBytes()));
}
catch (Exception ex)
{
ex.printStackTrace();
}
return resultString.toUpperCase();
}
}



是获取本机物理地址 加密吗? 用的什么加密算法~~
然后怎么才能登陆呢
...全文
1414 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
servet_stu 2019-06-28
  • 打赏
  • 举报
回复
$(function(){

$.ajax({
type:"post",
url:"AjaxServlet",
dataType:"json",
async:true,
traditional: true,
success:function(data){
var classes = $("#classes");
$.each(data,function(index,va){
classes.append(
"<option value = '"+va.id+"'>"+va.className+"</option>"
);
})
}

});

$("#classes").change(function(){
var students = $("#students");
students.empty();
$.ajax({
type:"post",
url:"AjaxServlet",
data:{action:"true",cId:$("#classes").val()},
dataType:"json",
async:true,
traditional:true,
success:function(data){
students.append("<option selected>--请选择--</option>");
$.each(data,function(index,va){
students.append(
"<option value = '"+va.id+"'>"+va.name+"</option>"
);

})
}
});

});

$("#students").change(function(){

var code = $("#code");
var age = $("#age");
var phone = $("#phone");

code.empty();
age.empty();
phone.empty();

$.ajax({
type:"post",
url:"Ajax2Servlet",
data:{id:$("#students").val()},
dataType:"json",
async:true,
traditional:true,
success:function(data){
code.text("Code: "+data.code);
age.text("Age: "+data.age);
phone.text("Phone: "+data.phone);
}
});
});


});
yklnyc 2018-06-05
  • 打赏
  • 举报
回复
https://pan.baidu.com/s/1K9-j9fE5ToNAK3lXF9-CUA 源文件

50,547

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧