我想加密一个字符串而不将其写入文件。
使用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?
尝试还原加密备份时,即使副本具有从生成备份的原始/主服务器还原的主密钥(dmk),服务主密钥,证书和私钥,在辅助副本上也遇到以下错误。
Msg 15581, Level 16, State 7, Line 137
Please create a master key in the database or open the master key in the session before performing this operation.
Msg 3013, Level 16, State 1, Line 137
VERIFY DATABASE is terminating abnormally.
Run Code Online (Sandbox Code Playgroud)
为了避免错误,我围绕此类操作打开和关闭主键。但是,在主数据库上,我不需要打开和关闭主键即可进行操作。
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'MyTest!M4st3rPass';
RESTORE VERIFYONLY FROM DISK = '\\FS1\SqlBackups\SQL01\SystemDbs\msdb_backup_2017_09_22_171915_6346240.bak' WITH FILE = 1, NOUNLOAD, NOREWIND;
CLOSE MASTER KEY ;
Run Code Online (Sandbox Code Playgroud)
我相信这是因为主数据库具有加密指纹的备份历史记录,但是我想知道是否遗漏了与第二数据库有关的其他内容。
但是,毕竟,由于该证书已在第二副本上还原,因此我将其分配给用于备份加密的SystemsDB备份维护计划选项,但是如果出于相同原因而选中“验证”选项,则该作业将失败。
Source: Back Up Database Task
Executing query "BACKUP DATABASE [master] TO …Run Code Online (Sandbox Code Playgroud) 带加密的ElastiCache使用TLS与redis客户端通信,但正如我所见,所有语言的redis客户端(ioredis,predis,go-redis)在将客户端配置为TLS时需要pem文件.
如果没有TLS的证书,我如何使用传输中加密连接到Elasticache?
我需要加密将存储在数据库中的聊天消息。数据是一串不同长度的字符。我想使用本机 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) 我正在使用Web Crypto API并使用generateKey函数生成RSA 密钥对。由于我的代码中存在一些错误,我删除了一些用户的公钥。我想知道是否有任何方法可以从私钥生成公钥?我知道这对于 ssh 密钥来说很容易实现。这是我生成 RSA 密钥对的示例代码:
const generateRSAKeys = (): Promise<CryptoKeyPair> => {
return crypto.subtle.generateKey(
{
name: 'RSA-OAEP',
modulusLength: 2048
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: { name: 'SHA-512' },
},
true,
['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'],
);
Run Code Online (Sandbox Code Playgroud) javascript encryption rsa encryption-asymmetric webcrypto-api
我知道用 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() …
encryption ×10
javascript ×2
android ×1
certificate ×1
cryptography ×1
docker ×1
dotnetzip ×1
file ×1
gnupg ×1
ionic-zip ×1
java ×1
node.js ×1
passwords ×1
postgresql ×1
private-key ×1
redis ×1
rsa ×1
sql ×1
webdeploy ×1