Mercurial Hosting > luan
comparison src/luan/modules/url/LuanUrl.java @ 1649:f7e2df85fc0a
add String.digest_message
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2022 16:07:01 -0600 |
parents | 0160650180bc |
children | 83780735ad9c |
comparison
equal
deleted
inserted
replaced
1648:224af797b1f9 | 1649:f7e2df85fc0a |
---|---|
23 import luan.Luan; | 23 import luan.Luan; |
24 import luan.LuanTable; | 24 import luan.LuanTable; |
25 import luan.LuanJavaFunction; | 25 import luan.LuanJavaFunction; |
26 import luan.LuanException; | 26 import luan.LuanException; |
27 import luan.modules.IoLuan; | 27 import luan.modules.IoLuan; |
28 import luan.modules.StringLuan; | |
28 import luan.modules.Utils; | 29 import luan.modules.Utils; |
29 | 30 |
30 | 31 |
31 public final class LuanUrl extends IoLuan.LuanIn { | 32 public final class LuanUrl extends IoLuan.LuanIn { |
32 | 33 |
377 if( query != null ) | 378 if( query != null ) |
378 path += "?" + query; | 379 path += "?" + query; |
379 return path; | 380 return path; |
380 } | 381 } |
381 | 382 |
382 // retarded java api lacks this | |
383 public static String md5(String s) { | 383 public static String md5(String s) { |
384 try { | 384 try { |
385 byte[] md5 = MessageDigest.getInstance("MD5").digest(s.getBytes()); | 385 return StringLuan.digest_message("MD5",s); |
386 StringBuffer sb = new StringBuffer(); | 386 } catch(LuanException e) { |
387 for( byte b : md5 ) { | 387 throw new RuntimeException(e); |
388 sb.append( String.format("%02x",b) ); | |
389 } | |
390 return sb.toString(); | |
391 } catch(NoSuchAlgorithmException e) { | 388 } catch(NoSuchAlgorithmException e) { |
392 throw new RuntimeException(e); | 389 throw new RuntimeException(e); |
393 } | 390 } |
394 } | 391 } |
395 | 392 |