JKS(Java密钥库)文件是否已加密?它们是否为加密密钥提供全面保护,还是仅仅依靠访问控制?
有没有办法确保密钥受到保护?
我对细节很感兴趣,包括算法,密钥管理等.这些都是可配置的吗?
我想加密一个字符串而不将其写入文件。
使用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?
我需要加密将存储在数据库中的聊天消息。数据是一串不同长度的字符。我想使用本机 node.js 加密库并使用对称加密协议,例如 AES 256。我担心以下问题:
TEXT?// 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) 我有以下加密代码
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) 我知道用 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)
但这段代码允许人们查看加密的文件和文件夹名称。如何防止存档(加密)文件和文件夹名称出现?
当您告诉 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
使用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() …
import { EncryptStorage } from 'encrypt-storage';
export const encryptStorage = EncryptStorage('secret_key');
encryptStorage.setItem('user', userObj);
Run Code Online (Sandbox Code Playgroud)
错误 :
我正在尝试使用加密存储来加密本地存储,但是导入给了我错误,并且在仅输入 3 行代码后项目崩溃了。
next 的动态导入不起作用,因为我找到的大多数解决方案都是针对组件而不是包。
该解决方案不适用于动态模块导入,因为我在加载程序中遇到一些分配错误。
提前致谢。:)
我将公钥作为字符串存储在环境变量中。该公钥来自 .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
encryption ×10
java ×2
javascript ×2
node.js ×2
android ×1
cryptography ×1
docker ×1
dotnetzip ×1
file ×1
gnupg ×1
ionic-zip ×1
jks ×1
next.js ×1
passwords ×1
postgresql ×1
public-key ×1
reactjs ×1
security ×1
webdeploy ×1