equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2010, Isode Limited, London, England. |
|
3 * All rights reserved. |
|
4 */ |
|
5 /* |
|
6 * Copyright (c) 2010, Remko Tronçon. |
|
7 * All rights reserved. |
|
8 */ |
|
9 package com.isode.stroke.stringcodecs; |
|
10 |
|
11 import com.isode.stroke.base.ByteArray; |
|
12 import java.security.MessageDigest; |
|
13 import java.security.NoSuchAlgorithmException; |
|
14 |
|
15 public class SHA1 { |
|
16 |
|
17 public static ByteArray getHash(ByteArray data) { |
|
18 MessageDigest md; |
|
19 try { |
|
20 md = MessageDigest.getInstance("SHA-1"); |
|
21 } catch (NoSuchAlgorithmException ex) { |
|
22 throw new IllegalStateException("JRE doesn't have an SHA hash function", ex); |
|
23 } |
|
24 md.update(data.getData()); |
|
25 return new ByteArray(md.digest()); |
|
26 } |
|
27 } |