get string MD5
import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
class cassandraMD5{
static final Scanner cin=new Scanner(System.in);
public static byte[] hash(String type, byte[]... data){
byte[] result = null;
try{
MessageDigest messageDigest = MessageDigest.getInstance(type);
for(byte[] block : data)
messageDigest.update(block);
result = messageDigest.digest();
}
catch (Exception e){
throw new RuntimeException(e);
}
return result;
}
public static BigInteger hash(String data){
byte[] result = null;
try {
result = hash("MD5", data.getBytes("UTF8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BigInteger hash = new BigInteger(result);
return hash.abs();
}
public static void main(String[] args){
while(cin.hasNext()){
String str1=cin.next();
BigInteger a= hash(str1);
System.out.println(a);
}
BigInteger a= hash(str2);
System.out.println(a);
}
}[@more@]
import java.util.*;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
class cassandraMD5{
static final Scanner cin=new Scanner(System.in);
public static byte[] hash(String type, byte[]... data){
byte[] result = null;
try{
MessageDigest messageDigest = MessageDigest.getInstance(type);
for(byte[] block : data)
messageDigest.update(block);
result = messageDigest.digest();
}
catch (Exception e){
throw new RuntimeException(e);
}
return result;
}
public static BigInteger hash(String data){
byte[] result = null;
try {
result = hash("MD5", data.getBytes("UTF8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BigInteger hash = new BigInteger(result);
return hash.abs();
}
public static void main(String[] args){
while(cin.hasNext()){
String str1=cin.next();
BigInteger a= hash(str1);
System.out.println(a);
}
BigInteger a= hash(str2);
System.out.println(a);
}
}[@more@]
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23937368/viewspace-1054900/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 求助:service中get要求key型別必須為string嗎型別
- flutter pub get 的時候:A dependency specification must be a string or a mapping.FlutterAPP
- JAVA中MD5加密(MD5工具類)Java加密
- md5解密解密
- MD5加密加密
- MD5和MD5破解的一些事
- MD5手機號線上解密 MD5解密解密
- 函式FUN_GET_SPOOL_STRING_LHR的內容--spool匯出csv檔案格式函式
- Visual C++ generate uuid via UuidCreate and CoCreateGuid,get time now,write string to fileC++GUI
- C# 實現MD5加密處理 MD5 加密C#加密
- java MD5 加密Java加密
- MD5簽名
- 【Java】MD5加密Java加密
- md5加密解密加密解密
- iOS MD5加密iOS加密
- java md5加密Java加密
- md5繞過
- MD5的使用
- String,String Builder,String Buffer-原始碼UI原始碼
- 字串函式 md5 ()字串函式
- Vue 前端md5加密Vue前端加密
- 關於MD5加密加密
- oracle md5函式Oracle函式
- oracle的md5加密Oracle加密
- MD5演算法演算法
- MD5碰撞試驗
- js計算md5JS
- MD5加密工具類加密
- Failed to execute user defined function(anonfun$concatStr$1: (map<string,string>, string) => string)AIFunction
- lombok get/set 與 JavaBean get/setLombokJavaBean
- String a = "abc" 與String b = new String("abc")的區別
- get的被動用法(get-passive)
- java.lang.String 與stringJava
- Oracle和MySQL md5加密OracleMySql加密
- qt實現md5加密QT加密
- Oracle中的MD5加密Oracle加密
- C# MD5 加密,解密C#加密解密
- MD5程式碼工具類