java项目易买网mysql_易买网项目源码【完整版】

1 packagecn.easybuy.utils;2

3 importjava.security.InvalidKeyException;4 importjava.security.NoSuchAlgorithmException;5 importjava.text.SimpleDateFormat;6 importjava.util.Calendar;7 importjava.util.Date;8 importjava.util.Map;9 importjava.util.Random;10 importjava.util.UUID;11

12 importjavax.crypto.BadPaddingException;13 importjavax.crypto.Cipher;14 importjavax.crypto.IllegalBlockSizeException;15 importjavax.crypto.NoSuchPaddingException;16 importjavax.crypto.SecretKey;17 importjavax.crypto.spec.SecretKeySpec;18

19

20

21 public classStringUtils {22 private static String[] binaryArray =

23 {"0000","0001","0010","0011",24 "0100","0101","0110","0111",25 "1000","1001","1010","1011",26 "1100","1101","1110","1111"};27 //private static String[] chineseDigits = new String[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};

28 public static String[] chineseDigits = new String[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};29

30 private static final char[] charBytes = { ‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘8‘, ‘9‘,‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘, ‘g‘, ‘h‘,31 ‘i‘,‘j‘,‘k‘,‘l‘,‘m‘,‘n‘,‘o‘,‘p‘,‘q‘,‘r‘,‘s‘,‘t‘,‘u‘,‘v‘,‘w‘,‘x‘,‘y‘,‘z‘};32

33 private static final char[] numberBytes = {‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘8‘, ‘9‘};34

35 /**

36 * 生成指定位数的随机数子.37 *@paramnumber38 *@return

39 */

40 public static String randomNumbers(intnumber) {41 int count = 0; //生成的密码的长度

42 int i; //生成的随机数

43 final int maxNum =numberBytes.length;44 StringBuffer randomStr = new StringBuffer("");45 Random r = newRandom();46 while(count

48 i = Math.abs(r.nextInt(maxNum)); //生成的数最大为36-1

49 if (i >= 0 && i

57

58

59 public static String randomStrByNumber(intnumber) {60 int count = 0; //生成的密码的长度

61 int i; //生成的随机数

62 final int maxNum =charBytes.length;63 StringBuffer randomStr = new StringBuffer("");64 Random r = newRandom();65 while(count

67 i = Math.abs(r.nextInt(maxNum)); //生成的数最大为36-1

68 if (i >= 0 && i

76

77 public staticString randomUUID() {78 UUID uuid =UUID.randomUUID();79 return uuid.toString().replace("-", "").toUpperCase();80 }81 public static String digitsTochinese(inti){82 //大于10的需要重写

83 returnchineseDigits[i];84 }85 public staticString toAllUpperCase(String uuid) {86 StringBuffer buffer = newStringBuffer();87

88 for (int i = 0; i < uuid.length(); i++) {89 char c =uuid.charAt(i);90 if(Character.isLowerCase(c)) {91 buffer.append(Character.toUpperCase(c));92 } else{93 buffer.append(c);94 }95 }96 returnbuffer.toString();97 }98

99

100

101 //十六进制字符串转byte数组

102 public static byte[] hexStringToBytes(String hexStrin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值