【发布时间】:2015-05-25 10:01:50
【问题描述】:
我已经使用this SO 帖子中提供的答案成功地为我的模型中的一个字段设置了加密。但我想知道如何从 SQL 客户端手动解密该字段以进行调试。我想要 Mysql(Prod 数据库)的这些信息,最好是 H2(开发数据库)。根据 E-bean 文档,Mysql 使用 AES_ENCRYPT/AES_DECRYPT 而 H2 使用 ENCRYPT/DECRYPT 函数。
@Encrypted
@Column(columnDefinition="varchar(50)")
public String password;
注意:我已将加密字段的数据类型设置为 varchar 而不是二进制,如下所示。因此,Ebean 可能会另外对生成的二进制数据进行 Hex。
class CustomEncryptKey implements EncryptKey{
private String tableName;
private String columnName;
public CustomEncryptKey(String tableName, String columnName){
this.tableName = tableName;
this.columnName = columnName;
}
@Override
public String getStringValue() {
return "my-encryption-key";
}
}
【问题讨论】:
标签: mysql encryption playframework-2.0 ebean