cipherfactory.java
来自「非常棒的java数据库」· Java 代码 · 共 37 行
JAVA
37 行
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.security;
import java.sql.SQLException;
import org.h2.constant.ErrorCode;
import org.h2.message.Message;
/**
* A factory to create new block cipher objects.
*/
public class CipherFactory {
public static BlockCipher getBlockCipher(String algorithm) throws SQLException {
if ("XTEA".equalsIgnoreCase(algorithm)) {
return new XTEA();
} else if ("AES".equalsIgnoreCase(algorithm)) {
return new AES();
} else {
throw Message.getSQLException(ErrorCode.UNSUPPORTED_CIPHER, algorithm);
}
}
public static SHA256 getHash(String algorithm) throws SQLException {
if ("SHA256".equalsIgnoreCase(algorithm)) {
return new SHA256();
} else {
throw Message.getInvalidValueException(algorithm, "algorithm");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?