1 5 package org.h2.security; 6 7 import java.sql.SQLException ; 8 9 import org.h2.message.Message; 10 11 public class CipherFactory { 12 13 public static BlockCipher getBlockCipher(String algorithm) throws SQLException { 14 if ("XTEA".equalsIgnoreCase(algorithm)) { 15 return new XTEA(); 16 } else if ("AES".equalsIgnoreCase(algorithm)) { 17 return new AES(); 18 } else { 19 throw Message.getSQLException(Message.UNSUPPORTED_CIPHER, algorithm); 20 } 21 } 22 23 public static SHA256 getHash(String algorithm) throws SQLException { 24 if("SHA256".equalsIgnoreCase(algorithm)) { 25 return new SHA256(); 26 } else { 27 throw Message.getInvalidValueException(algorithm, "algorithm"); 28 } 29 } 30 31 } 32 | Popular Tags |