Changeset 7313


Ignore:
Timestamp:
12/03/10 10:31:49 (9 years ago)
Author:
callan
Message:

Test.java (from  omero:#3627) port to a full blown TestNG test case also covering various different block sizes.

Location:
trunk/components/test-suite/src/loci/tests/testng
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/test-suite/src/loci/tests/testng/TestTools.java

    r6881 r7313  
    7777  } 
    7878 
     79  /** Calculate the SHA-1 of a byte array. */ 
     80  public static String sha1(byte[] b, int offset, int len) { 
     81    try { 
     82      MessageDigest md = MessageDigest.getInstance("SHA-1"); 
     83      md.reset(); 
     84      md.update(b, offset, len); 
     85      byte[] digest = md.digest(); 
     86      return DataTools.bytesToHex(digest); 
     87    } 
     88    catch (NoSuchAlgorithmException e) { } 
     89    return null; 
     90  } 
     91 
     92  /** Calculate the SHA-1 of a byte array. */ 
     93  public static String sha1(byte[] b) { 
     94    try { 
     95      MessageDigest md = MessageDigest.getInstance("SHA-1"); 
     96      md.reset(); 
     97      md.update(b); 
     98      byte[] digest = md.digest(); 
     99      return DataTools.bytesToHex(digest); 
     100    } 
     101    catch (NoSuchAlgorithmException e) { } 
     102    return null; 
     103  } 
     104 
     105  /** Calculate the MD5 of a byte array. */ 
     106  public static String md5(byte[] b, int offset, int len) { 
     107    try { 
     108      MessageDigest md = MessageDigest.getInstance("MD5"); 
     109      md.reset(); 
     110      md.update(b, offset, len); 
     111      byte[] digest = md.digest(); 
     112      return DataTools.bytesToHex(digest); 
     113    } 
     114    catch (NoSuchAlgorithmException e) { } 
     115    return null; 
     116  } 
     117 
    79118  /** Calculate the MD5 of a byte array. */ 
    80119  public static String md5(byte[] b) { 
Note: See TracChangeset for help on using the changeset viewer.