简体   繁体   English

Perl - SQLite3数据库加密

[英]Perl - SQLite3 DB encryption

I successfully managed to create a SQLite3 DB with Perl using Perl::DBI module. 我成功地使用Perl :: DBI模块使用Perl创建了一个SQLite3数据库。 I was wondering if there was a way to add encryption to the database to my existing Perl code ? 我想知道是否有办法将数据库的加密添加到我现有的Perl代码中?

I read thoroughly the 2 following links : 我仔细阅读了以下2个链接:

but the provided examples seem only to include proprietary software or C# code (especially this bit here https://stackoverflow.com/a/24349415/3186538 ). 但提供的示例似乎只包括专有软件或C#代码(特别是这一点https://stackoverflow.com/a/24349415/3186538 )。

Thanks in advance. 提前致谢。

Well, you could run your data through any of the Crypt::* modules ( ::DES , ::Blowfish , ::IDEA , etc, in conjunction with ::CBC ), then possibly encode it with base64 to get text, before writing it to the DB. 好吧,您可以通过任何Crypt::*模块( ::DES::Blowfish::IDEA等,与::CBC结合)运行您的数据,然后可能使用base64对其进行编码以获取文本把它写到DB。 And, of course, reverse the operation when reading. 当然,在阅读时反转操作。 You could even create a Perl::DBICrypt module that sat above Perl::DBI and did this automagically. 您甚至可以创建一个位于Perl::DBI之上的Perl::DBICrypt模块,并自动完成此操作。

However, it depends pretty much on how you're going to use it. 但是,这很大程度上取决于你将如何使用它。 If you're just worried about someone stealing and using your data, the encryption would be feasible since, without the key, it would be useless. 如果您只是担心有人窃取和使用您的数据,加密将是可行的,因为没有密钥,它将是无用的。

On the other hand, if you're trying to protect data in a system you distribute, then the key will be available to the attacker (since, without it, your code won't work). 另一方面,如果您尝试保护您分发的系统中的数据,则攻击者可以使用该密钥(因为没有它,您的代码将无法运行)。 So encrypting in that case would be a minor inconvenience at best. 因此,在这种情况下加密最多只是一个小小的不便。

It's something that could only really work if you kept the key away from the attacker (such as if the Perl code runs in an app server controlled by you). 如果您将密钥远离攻击者(例如,如果Perl代码在您控制的应用服务器中运行),那么这些功能才能真正起作用。

Basically any solution that decrypts data on a box accessible to an attacker will be vulnerable. 基本上任何解密攻击者可访问的盒子上的数据的解决方案都是易受攻击的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM