我们最近将我们的 Oracle 数据库配置为所谓的native encryption(Oracle Advanced Security Option)。
随着开发的进行,有些SQL查询有时会写得很糟糕,因此JDBC驱动程序应该返回一个错误( ojdbc7 v12.1.0.2)。取而代之的是, aChecksum Fail IOException被提出。
所以问题是我们根本没有任何语法或数据库完整性错误。这个问题在 SQL GUI 编辑器中是一样的,比如DBeaver,SQLDeveloper或SQuirrel.
我对 AES 加密和解密非常陌生。在我的应用程序中,我必须解密从服务器获得的数据。我收到的数据是使用 CryptoJS 库加密的。解密工作得很好。但是在将数据发布到服务器时,我必须再次加密数据并将其发送到服务器,这没有提供适当的加密。我已按照此堆栈溢出答案进行解密,该答案工作正常。我将在下面发布我的解密代码。请帮忙。
对于解密:
public static String Decrypt(String Encrpyt , String Key ) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
byte[] cipherData = Base64.decode(Encrpyt, Base64.DEFAULT);
byte[] saltData = Arrays.copyOfRange(cipherData, 8, 16);
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
final byte[][] keyAndIV = GenerateKeyAndIV(32, 16, 1, saltData, Key.getBytes(StandardCharsets.UTF_8), md5);
SecretKeySpec key = new SecretKeySpec(keyAndIV[0], "AES");
IvParameterSpec iv = new IvParameterSpec(keyAndIV[1]);
byte[] encrypted = Arrays.copyOfRange(cipherData, 16, …Run Code Online (Sandbox Code Playgroud) 我刚刚得到了我的 twitter oauth 令牌(OAuth 1.0a),所以在我将它存储到数据库之前,我有一个问题:我需要加密它吗?
一个类似的问题被张贴在这里。
答案是:
因此,如果用户还没有用于完全访问的 consumer_key 和 consumer_secret,那么仅从您的数据库中获取用户的 access_token 将无济于事。
服务提供商根据请求比较所有 4 个参数。在存储之前加密这 4 个参数并在响应之前解密它们是明智的。
如果黑客不能只用 oauth 令牌做任何事情,那我为什么要加密它?
据我所知,如果黑客可以使用 oauth 令牌获取我的消费者密钥,他也会将我的加密密钥存储在运行该应用程序的服务器上。
目前,我使用EncryptedTypefromsqlalchemy_utils来自动加密进入表的数据,并在从表中检索数据时解密数据,使用一些预定义的字符串作为加密密钥。这工作正常,但现在需求发生了变化,虽然我仍然需要在进入表的路上加密数据,但我现在需要在检索数据时保持加密。我不确定这是否EncryptedType支持,或者是否有任何其他方法可以使用 SQLAlchemy 来做到这一点,而无需在我假设的密码库中使用我自己的方法。
我的表的例子:
class MyTable(db.Model):
__tablename__ = "my_table"
id = db.Column(db.Integer, primary_key=True, autoincrement="auto")
name = db.Column(db.String(50), nullable=False)
username = db.Column(EncryptedType(db.String, _key), nullable=True)
password = db.Column(EncryptedType(db.String, _key), nullable=True)
Run Code Online (Sandbox Code Playgroud) 如果用户输入了错误的 AES 解密密钥,就会产生一些垃圾数据。我想验证给定的解密密钥并在密钥不正确时抛出错误。如何验证用户输入的密钥?
干杯。这是我关于加密堆栈交换的问题的副本。
我正在通过PKCS#11 C/Python 接口处理HSM。我想知道是否可以在硬件中做一些/ 。通过说“在硬件中”,我的意思是加密/解密而不将结果暴露给调用者空间。这主要是关于解密,因为我想调用并将结果作为任意数据保留在 HSM 中,以便稍后对该数据进行一些其他转换,并说在其他一些密钥上重新加密它。先感谢您。C_EncryptC_DecryptC_Decrypt
我一直在研究如何使用Laravel 加密,因为构建宅基地加密平台是不受欢迎的,也是理所当然的。
Illuminate\Support\Facades\Crypt::encryptString('This is a secret message from user 1 to user 2');
Run Code Online (Sandbox Code Playgroud)
以上面的例子为例,这是使用APP_KEY从我的.env文件派生的 my ,以前由php artisan key:generate. 问题是用户 1 永远不会被分配两组密钥来仅与用户 2通信。用户 3、4 等仍然可以使用该Illuminate\Support\Facades\Crypt::decryptString方法读取此消息。
目前,我的数据库设置为具有聊天标题。这包含的信息有什么是通信。所有参与者都将使用这些密钥进行加密和解密——因此任何外部用户都无法解密消息。
public function up()
{
Schema::create('chat_headers', function(Blueprint $table) {
$table->increments('id');
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
$table->string('private_key')->unique();
$table->string('public_key')->unique();
});
}
Run Code Online (Sandbox Code Playgroud)
我也有一个聊天参与者,其中包含有关谁在通信的信息:
public function up()
{
Schema::create('chat_participants', function(Blueprint $table) {
$table->increments('id');
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
$table->integer('user_id')->unsigned();
# TODO: Build RBAC
$table->index(['user_id']); …Run Code Online (Sandbox Code Playgroud) 我目前正在使用window.crypto.subtle.encryptJavascript 中的网络加密 API 。我的问题是,默认情况下使用什么填充?我已经搜索了一段时间,但找不到任何答案。
我有一个使用 gpg 创建对称加密文件的过程:
gpg --batch --passphrase=mypassphrase -c configure.txt
Run Code Online (Sandbox Code Playgroud)
gpg只要我有密码,我就可以对任何用户解密加密文件。这正如预期的那样。
然后我运行了一个 python 服务,它定期下载这个文件,解密它,并使用定义的配置。好吧,它应该解密它,但事实并非如此。这是一个代码清单:
import urllib.request
import gnupg
gpg = gnupg.GPG()
key = 'mypassphrase'
response = urllib.request.urlopen('http://www.example.org/configure.txt.gpg')
encrypted_file = response.read()
file = gpg.decrypt(encrypted_file, passphrase=key)
print(str(file))
Run Code Online (Sandbox Code Playgroud)
该print是空白。如果我检查file对象,我会看到这些属性:
{
'_gpg': <gnupg.gnupg.GPG object at 0x7f3d84675a90>,
'valid': False,
'status': 'decrypt 4294967295',
'fingerprint': None,
'pubkey_fingerprint': None,
'key_id': None,
'signature_id': None,
'creation_date': None,
'timestamp': None,
'sig_timestamp': None,
'username': None,
'expire_timestamp': None,
'trust_level': None,
'trust_text': None,
'subpackets': {},
'notations': {},
'_last_notation_name': None,
'data': b'', …Run Code Online (Sandbox Code Playgroud) 在我的 Web 应用程序中,当用户注销我的应用程序并在再次登录后恢复它时,我试图将数据存储在本地存储中。此数据是私有的,因此在保存之前需要对其进行加密。由于该要求,该过程如下所示:
加密:
解密:
这是代码(打字稿):
interface Data {
queue: string;
initializationVector: string;
date: string;
}
private getEncryptionKey(): void {
const date: string = this.getDateParamForEncryptionKeyGeneration();
const params = new HttpParams().set('date', date);
this.encryptionKeyDate = DateSerializer.deserialize(date);
this.http.get(this.ENCRYPTION_KEY_ENDPOINT, {params}).subscribe((response: {key: string}) => {
const seed = response.key.slice(0, 32);
window.crypto.subtle.importKey(
'raw',
new TextEncoder().encode(seed),
'AES-GCM',
true,
['encrypt', 'decrypt']
).then(
(key: CryptoKey) => {
this.encryptionKey = key;
this.decrypt();
}
);
}); …Run Code Online (Sandbox Code Playgroud) encryption ×10
cryptography ×3
aes ×2
java ×2
python ×2
android ×1
gnupg ×1
hardware ×1
java-7 ×1
javascript ×1
jdbc ×1
laravel ×1
laravel-5 ×1
oauth ×1
oracle ×1
php ×1
pkcs#11 ×1
sqlalchemy ×1
typescript ×1