标签: encryption

JKS保护

JKS(Java密钥库)文件是否已加密?它们是否为加密密钥提供全面保护,还是仅仅依靠访问控制?
有没有办法确保密钥受到保护?

我对细节很感兴趣,包括算法,密钥管理等.这些都是可配置的吗?

java security encryption jks

7
推荐指数
2
解决办法
3406
查看次数

是否可以对 gpg 中的原始输入进行加密?

我想加密一个字符串而不将其写入文件。

使用GPG加密文件的方法是

gpg --encrypt --sign --armor -r <target@email.com> -r <sender@email.com> <filename.txt>
Run Code Online (Sandbox Code Playgroud)

我想要的是能够简单地输入 filename.txt 所在的字符串或一系列数字,并将其加密到文件中。

gpg --encrypt --sign --armor -r <target@email.com> -r <sender@email.com> <"this is a string that needs to be encrypted">
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点,或者是否需要传入 filename.txt?

encryption gnupg

7
推荐指数
1
解决办法
7038
查看次数

我是否正确执行 AES 256 加密和解密 Node.js?

我需要加密将存储在数据库中的聊天消息。数据是一串不同长度的字符。我想使用本机 node.js 加密库并使用对称加密协议,例如 AES 256。我担心以下问题:

  1. 对于存储在 MySQL 中的字段中的此类字段,CBC 是此用例的正确 AES 模式吗TEXT?
  2. 密钥看起来是否正确生成?
  3. IV 正确吗?在加密文本前添加 IV 是正确的方法还是应该将其作为一个单独的字段?
// AES RFC - https://tools.ietf.org/html/rfc3602
const crypto = require('crypto');

const algorithm = 'aes-256-cbc';
// generate key with crypto.randomBytes(256/8).toString('hex')
const key = '6d858102402dbbeb0f9bb711e3d13a1229684792db4940db0d0e71c08ca602e1';
const IV_LENGTH = 16;

const encrypt = (text) => {
  const iv = crypto.randomBytes(IV_LENGTH);
  const cipher = crypto.createCipheriv(algorithm, Buffer.from(key, 'hex'), iv);
  let encrypted = cipher.update(text);
  encrypted = Buffer.concat([encrypted, cipher.final()]);
  return `${iv.toString('hex')}:${encrypted.toString('hex')}`;
};

const decrypt = (text) => {
  const [iv, …
Run Code Online (Sandbox Code Playgroud)

javascript encryption encryption-symmetric node.js

7
推荐指数
1
解决办法
1万
查看次数

javax.crypto.BadPaddingException:填充块有时会损坏

我有以下加密代码

public static String encrypt(String value, char[] secret) {
        try {
            final byte[] bytes = value != null ? value.getBytes(StandardCharsets.UTF_8) : new byte[0];
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
            SecretKey key = keyFactory.generateSecret(new PBEKeySpec(secret));
            Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
            pbeCipher.init(Cipher.ENCRYPT_MODE, key, new PBEParameterSpec(IsoGame.$().crossPlatformManager.getCrossPlatformUtilsInstance().getDeviceUniqueIdentifier().getBytes(StandardCharsets.UTF_8), 20));
            return new String(Base64.encodeBase64(pbeCipher.doFinal(bytes)), StandardCharsets.UTF_8);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return value;

    }
Run Code Online (Sandbox Code Playgroud)

以及以下解密代码。

public static String decrypt(String value, char[] secret) {
        try {
            final byte[] bytes = value != null ? Base64.decodeBase64(value.getBytes(StandardCharsets.UTF_8)) : new byte[0];
            SecretKeyFactory keyFactory …
Run Code Online (Sandbox Code Playgroud)

java encryption cryptography sharedpreferences

7
推荐指数
1
解决办法
2万
查看次数

加密档案中的文件名,防止在 C# 中使用 ionic.zip 显示内容列表

我知道用 ionic.zip 压缩文件,如下所示:

using (var zip = new ZipFile())
{
    zip.Encryption = EncryptionAlgorithm.WinZipAes256;
    zip.Password = "123";
    zip.AddDirectory("/path/");
    zip.SaveProgress += Zip_ProgressBar;
    zip.Save("/path/");
}
Run Code Online (Sandbox Code Playgroud)

但这段代码允许人们查看加密的文件和文件夹名称。如何防止存档(加密)文件和文件夹名称出现?

encryption dotnetzip ionic-zip

7
推荐指数
0
解决办法
2025
查看次数

Visual Studio 如何加密 .pubxml.user 文件中的密码?

当您告诉 Visual Studio 保存发布配置文件的密码时,它会.pubxml.user在您的发布文件旁边创建一个文件,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <TimeStampOfAssociatedLegacyPublishXmlFile />
    <EncryptedPassword>AQAAANC[...]</EncryptedPassword>
  </PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

Visual Studio 实际上如何加密元素中的密码EncryptedPassword?我想解密它,因为我忘记了密码......现在它只是加密存储在这个文件中!

encryption passwords visual-studio webdeploy visual-studio-2019

7
推荐指数
1
解决办法
1125
查看次数

Docker PostgreSQL 静态数据加密

根据手册,PostgreSQL 支持“数据分区加密”,以便将静态加密的数据存储在系统上。

对于我的下一个应用程序,我想使用 Docker 容器化 PostgreSQL。不幸的是,我没有找到任何选项来加密此 Docker 容器中的数据库文件以保护数据。我想过一些事情,比如当容器在运行时开始解密所有需要的文件时输入密码。

有没有人有这方面的经验?

encryption postgresql docker

7
推荐指数
1
解决办法
773
查看次数

如何在 Android 上覆盖 EncryptedFile?

使用Android的EncryptedFile(androidx.security:security-crypto:1.1.0-alpha01),我可以使用以下代码成功写入文件

File file = new File(context.getFilesDir() + File.separator + filename);
KeyGenParameterSpec keyGenParameterSpec = MasterKeys.AES256_GCM_SPEC;
EncryptedFile encryptedFile = null;
try {
    String masterKeyAlias = MasterKeys.getOrCreate(keyGenParameterSpec);
    encryptedFile = new EncryptedFile.Builder(
            file,
            context,
            masterKeyAlias,
            EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
    ).build();
} catch (Exception exception) {
    // log error
}

// write file
try {
    BufferedWriter bufferedWriter = new BufferedWriter(
            new OutputStreamWriter(encryptedFile.openFileOutput()));
    bufferedWriter.write(string);
    bufferedWriter.close();
} catch (Exception exception) {
    // log error
}
Run Code Online (Sandbox Code Playgroud)

但是,当试图覆盖同一个文件时,写操作失败并抛出以下内容

java.io.IOException: output file already exists, please use a new file
Run Code Online (Sandbox Code Playgroud)

我发现这是对 EncryptedFile 的显式检查 openFileOutput() …

encryption android file

7
推荐指数
0
解决办法
469
查看次数

新模块导入错误=&gt;“ReferenceError:self未定义”

import { EncryptStorage } from 'encrypt-storage';

export const encryptStorage = EncryptStorage('secret_key');

encryptStorage.setItem('user', userObj);
Run Code Online (Sandbox Code Playgroud)

错误 :

在此输入图像描述

我正在尝试使用加密存储来加密本地存储,但是导入给了我错误,并且在仅输入 3 行代码后项目崩溃了。

next 的动态导入不起作用,因为我找到的大多数解决方案都是针对组件而不是包。

该解决方案不适用于动态模块导入,因为我在加载程序中遇到一些分配错误。

提前致谢。:)

encryption local-storage reactjs next.js

7
推荐指数
0
解决办法
4417
查看次数

从 .env 文件访问 .pem 公钥

我将公钥作为字符串存储在环境变量中。该公钥来自 .pem 文件。当我尝试在代码中使用它时,出现以下错误

error:0909006C:PEM routines:get_name:no start line
Run Code Online (Sandbox Code Playgroud)

我已经尝试过其他用户的建议,将其转换为 base64 然后使用密钥,但我仍然遇到相同的错误。

公钥的 env 变量

PUB_KEY='-----BEGIN PUBLIC KEY-----randomgibberish-----END PUBLIC KEY-----'
Run Code Online (Sandbox Code Playgroud)

将其转换为base64的代码

const pubKey = process.env.PUB_KEY
const buff = Buffer.from(pubKey).toString('base64');
console.log(buff)
Run Code Online (Sandbox Code Playgroud)

在此处的 createPublicKey 方法中使用它

crypto.createPublicKey({
                key: buff,
                format: 'pem',
            });
Run Code Online (Sandbox Code Playgroud)

知道可能出了什么问题吗?TIA

javascript encryption environment-variables node.js public-key

7
推荐指数
1
解决办法
5126
查看次数