java代码生成md5
public void testMD4() { try { MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] b = digest.digest("123456".getBytes("UTF-8")); StringBuilder sb = new StringBuilder(); for (byte bt : b) { int ibt = bt & 0xff;//抹掉高位 if (ibt < 16) { sb.append(0); } sb.append(Integer.toHexString(ibt)); } System.out.println(sb.toString()); } catch (Exception e) { e.printStackTrace(); } }
golang服务器端生成md5
package main import ( "crypto/md5" "fmt" "io" ) func main() { h := md5.New() //向h中写入种子 seed := "123456" io.WriteString(h,seed) fmt.Println("golang生成的加密后的byte数组---->",h.Sum(nil)) //生成唯一字符串 str := fmt.Sprintf("%x",h.Sum(nil)) fmt.Println("golang生成的加密后的字符串---->",str) }原文链接:https://www.f2er.com/go/190367.html