使用暴露的JetBrains时加密字段

时间:2018-11-01 00:15:57

标签: encryption kotlin dao jetbrains-ide

是否有一种简单的方法可以将加密字段功能添加到Kotlin的JetBrains Exposed数据库框架中?

https://github.com/JetBrains/Exposed

1 个答案:

答案 0 :(得分:0)

从VarCharColumnType派生SecureVarchar列类型,并在表中使用该类型。

class SecureVarCharColumnType(val l:Int = 255,c:String?= null):VarCharColumnType(l,c){

override fun valueToDB(value: Any?): Any? = value?.let {
    return notNullValueToDB(Crypto.encrypt(it.toString()));
}

override fun valueFromDB(value: Any): Any {
    return Crypto.decrypt(value.toString())
}

}

object Users:IntIdTable(“ user”){     val email = super.registerColumn(“ email”,SecureVarCharColumnType(255))     ..... }