A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.text.DecimalFormat;
  5. import java.text.NumberFormat;
  6. import java.text.SimpleDateFormat;
  7. import java.util.Calendar;


  8. public class MyEclipseKeyGen {
  9. private static final String LL = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.";


  10. public String getSerial(String userId, String type) {
  11. NumberFormat nf = new DecimalFormat("000");
  12. Calendar cal = Calendar.getInstance();
  13. cal.add(Calendar.YEAR, 3);
  14. cal.add(Calendar.DAY_OF_YEAR, -1);
  15. String licenseNum = nf.format((int) (Math.random() * 1000));
  16. String expTime = new StringBuilder("-").append(
  17. new SimpleDateFormat("yyMMdd").format(cal.getTime())).append(
  18. "0").toString();
  19. String need = new StringBuilder(userId.substring(0, 1)).append("Y")
  20. .append(type).append("-100").append(licenseNum).append(expTime)
  21. .toString();
  22. String dx = new StringBuilder(need).append(LL).append(userId)
  23. .toString();
  24. int suf = this.decode(dx);
  25. String code = new StringBuilder(need).append(String.valueOf(suf))
  26. .toString();
  27. return this.change(code);
  28. }


  29. private int decode(String s) {
  30. int i;
  31. char[] ac;
  32. int j;
  33. int k;
  34. i = 0;
  35. ac = s.toCharArray();
  36. j = 0;
  37. k = ac.length;
  38. while (j < k) {
  39. i = (31 * i) + ac[j];
  40. j++;
  41. }
  42. return Math.abs(i);
  43. }


  44. private String change(String s) {
  45. byte[] abyte0;
  46. char[] ac;
  47. int i;
  48. int k;
  49. int j;
  50. abyte0 = s.getBytes();
  51. ac = new char[s.length()];
  52. i = 0;
  53. k = abyte0.length;
  54. while (i < k) {
  55. j = abyte0[i];
  56. if ((j >= 48) && (j <= 57)) {
  57. j = (((j - 48) + 5) % 10) + 48;
  58. } else if ((j >= 65) && (j <= 90)) {
  59. j = (((j - 65) + 13) % 26) + 65;
  60. } else if ((j >= 97) && (j <= 122)) {
  61. j = (((j - 97) + 13) % 26) + 97;
  62. }
  63. ac[i] = (char) j;
  64. i++;
  65. }
  66. return String.valueOf(ac);
  67. }


  68. public static void main(String[] args) {
  69. try {
  70. System.out.println("please input register name:");
  71. BufferedReader reader = new BufferedReader(new InputStreamReader(
  72. System.in));
  73. String userId = null;
  74. userId = reader.readLine();
  75. if(userId == null || "".equals(userId)){
  76. System.out.println("name is null");
  77. System.exit(0);
  78. }
  79. MyEclipseKeyGen myeclipsegen = new MyEclipseKeyGen();
  80. String res = myeclipsegen.getSerial(userId, "E3MS");
  81. System.out.println("Serial:" + res);
  82. reader.readLine();
  83. } catch (IOException ex) {
  84. ex.printStackTrace();
  85. }
  86. }
  87. }
复制代码
输入名字即可:
name:lizhen
key:yLR8ZF-655332-6059545238330702
MyEclipse注册码

评分

参与人数 2黑马币 +40 收起 理由
岳民喜 + 30 分享精神值得大家学习!
贠(yun)靖 + 10 要是自己写的,给我说一声给你3分,亲.

查看全部评分

3 个回复

正序浏览
  网上找的一段注册机代码,分享给大家,不好意思,不是我写的额。
回复 使用道具 举报
高手 。!!
回复 使用道具 举报
膜拜,高手啊,请问注册机什么原理。。 简单描述下
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马