因此,我计划使用 Jupyter notbook (Python 3) 进行一些数据分析,出于协作原因,我想将数据存储在 github 存储库中,但是数据集很敏感。
因此,我想将数据(当前为 .csv)作为加密文件存储在 repo 上,然后在运行时对其进行解密(我猜是密码提示)。
执行此操作的最佳方法是什么?
我有一个可以访问所有帐户的虚拟机。我下面的问题都是在同一个问题上运行的台机器,只是在不同的用户帐户下。
如果我登录domain\user1并运行以下 PowerShell 以生成一个字符串SecureString:
$SecurePassword = "ThisIsATest" | ConvertTo-SecureString -AsPlainText -Force
$RawSecureString = $SecurePassword | ConvertFrom-SecureString
Write-Host $RawSecureString
Run Code Online (Sandbox Code Playgroud)
所以输出如下:
$RawSecureString = "01000000d08c9ddf0115d1118c7a00c04fc297eb0100000014c54a4678625849adf32615ece5d33f000000000200000000001066000000010000200000007ece54f23781b598d0341c2380e678bc6286222186717e612e0f095b3edc4137000000000e80000000020000200000006b68df76dbc98fcd35943be7818c80ed502ec49d0ae06deeec183367ea19e10d200000002087d6178d6a67165d41ed172e11eae6bf7d648a59d25c01dd573baaad985bb040000000adc87d779c7de9d1565bcb834e50214e982c133c3558111138a2e1964b599d1bcb7b4583ff18d314f7bc6a0549bf03342a49ba2456cc13df60585ca36125ae37"
随着domain\user1我运行以下命令:
$SecureString = $RawSecureString | ConvertTo-SecureString
[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($SecureString))
Run Code Online (Sandbox Code Playgroud)
输出是 ThisIsATest,这很好。
如果我登录domain\user2并运行以下命令:
$RawSecureString = "01000000d08c9ddf0115d1118c7a00c04fc297eb0100000014c54a4678625849adf32615ece5d33f000000000200000000001066000000010000200000007ece54f23781b598d0341c2380e678bc6286222186717e612e0f095b3edc4137000000000e80000000020000200000006b68df76dbc98fcd35943be7818c80ed502ec49d0ae06deeec183367ea19e10d200000002087d6178d6a67165d41ed172e11eae6bf7d648a59d25c01dd573baaad985bb040000000adc87d779c7de9d1565bcb834e50214e982c133c3558111138a2e1964b599d1bcb7b4583ff18d314f7bc6a0549bf03342a49ba2456cc13df60585ca36125ae37"
$SecureString = $RawSecureString | ConvertTo-SecureString
[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($SecureString))
Run Code Online (Sandbox Code Playgroud)
我得到 Key not valid for use in specified state.,因为它是不同的用户。
由于在加密期间没有提供密钥user1,我的问题是,如果我有权访问两个登录帐户,是否有办法user2解密此安全字符串?
原因是我有许多虚拟机,其中的密钥作为本地管理帐户存储在注册表中,而我所做的大部分工作来自远程域帐户。
我在用:
这是我所做的:
获得了使用 OpenSSL 的自签名 ECC 证书以及https://gist.github.com/sidshetye/4759690上的脚本中概述的步骤,并进行了修改:
a) 在 256 位素数字段上使用 NIST/P-256 曲线
b) 使用 SHA-256
将文件(在上一步中生成)中的证书加载到 X509Certificate2 对象中
将 PFX 文件导入 Windows 信任存储(用于测试)。这是成功的。
我被困在最后一步,因为所有使用 X509Certificate2 对象的示例主要仅使用 RSA 而我使用的是 ECC 证书。对于 RSA 证书,X509Certificate2 上有GetRSAPublicKey扩展方法,RSA 类有Encrypt方法。但是,ECC 证书没有这种方法。
接下来,我偶然发现了这篇文章(使用带有 ECC 公钥的 X509Certificate2 加载证书)并尝试遵循以下方法(即使 ECC 证书公钥被强制转换为 RSA 类型的原因看起来很奇怪):
RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key
Run Code Online (Sandbox Code Playgroud)
我遇到以下异常:不支持证书密钥算法。
接下来我偶然发现了这篇文章(将基于 ECC 的证书从 Windows 证书存储导入 CngKey),它基本上试图创建 CNGKey …
我目前正在使用mcrypt.java来加密和解密来自服务器端的数据和客户端的cryptojs,但是我遇到了一些问题,因为当我加密任何字符串时,java和JavaScript都会显示不同的结果.
好吧,我正在阅读AES加密的方法和填充方案,一些博客谈论使用CBC模式与NoPadding不正确,并且更好/正确使用CBC与Pkcs7或其他填充.
任何人都能解释一下与此有关的事情吗?
我正在尝试使用PHP函数openssl_private_encrypt()在保存上载文件之前对其进行加密(请参见下面的代码片段),但是它的布尔值返回false,而加密的内容返回值则什么也不返回。没有错误正在显示或报告。
$data = file_get_contents($_FILES['files']['tmp_name'][0]);
openssl_private_encrypt($data,$encrypted,$key);
$hash = sha1($encrypted);
file_put_contents('/path/to/folder/'.$hash,$encrypted);
Run Code Online (Sandbox Code Playgroud)
是否有人对为什么它不起作用有任何想法?
谢谢
你好我正在研究JAVA中的仿射密码.我已经成功编写了加密代码,但现在我对解密逻辑没有任何了解.
以下是我的加密逻辑:
void encryption()
{
char character;
int plainTextLength=input.length();
int a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10,k=11,l=12,m=13,n=14,
o=15,p=16,q=17,r=18,s=19,t=20,u=21,v=22,w=23,x=24,y=25,z=26;
System.out.print("Cipher text is:" );
for (int in = 0; in < plainTextLength; in++)
{
character = input.charAt(in);
if (Character.isLetter(character))
{
character = (char)((firstKey*(character - 'a') + secondKey) % 26 + 'a');
}
System.out.print(character);
}
System.out.println();
}
Run Code Online (Sandbox Code Playgroud)
这是我的加密逻辑:character =(char)((firstKey*(character - 'a')+ secondKey)%26 +'a');
什么是解密逻辑.我完全糊涂了?
以下代码应该使用停止密码加密一个句子,它仍然是WIP我没有考虑空格,小写字母等.
int main(int argc,string argv[])
{
int k = atoi(argv[1]);
string value = GetString();
int n = strlen(value);
for(int i = 0;i<n; i++);
{
char temp = value[i];
int conv = temp - (int)'A';
int cipher = (conv + k)%26;
char final = cipher + (int)'A';
printf("%c\n",final);
}
}
Run Code Online (Sandbox Code Playgroud)
我明白了
caeser.c:15:23 use of undeclared identifier i.
Run Code Online (Sandbox Code Playgroud)
哪个就行了 char temp = value[i];
我有一个小的电子邮件程序,它进行加密.以下只是该计划的摘要:
private void sendEmailButton_Click(object sender, EventArgs e)
{
else
{
//////////////////////////////////////////////////////////////////////////
if (encryptEverythingCheckBox.Checked)
{
encryptAll();
}
//////////////////////////////////////////////////////////////////////////
// Email credentials network codes blahblah
// Assign the sender's email address to MailAddress function
MailAddress mailAddress = new MailAddress(username);
// Tells the recipent the sender's email
mailMessage.From = mailAddress;
// Username & Password of your email address
System.Net.NetworkCredential networkCredential;
networkCredential = new System.Net.NetworkCredential(username, password);
// Enable SSL to encypt the connection
smtpClient.EnableSsl = true;
// Disable the use of default credentials
smtpClient.UseDefaultCredentials …Run Code Online (Sandbox Code Playgroud) 我如何处理混淆文本,因此读取文本文件的用户无法读取,但我的程序仍然可以读取它?基本上,我会True*True*False*True*False*False*False*True*False*true*在文本文件中有类似的东西,我需要它看起来很疯狂.
我知道如何从文件中获取文本并写入文件和所有内容,我只需要弄清楚如何对字符串进行模糊处理并对其进行去混淆.这可能没有进入所有疯狂的加密东西吗?我认为AES和其他加密方法都是矫枉过正,因为在我的程序中,这些信息并不是绝密或其他什么,它可以在程序中查看.我只是不希望它直接通过文件编辑.
谢谢一堆:D
弥敦道
我正在编写一个解密存储在文件中的文本的Android应用程序.我用了以下代码 -
public class SimpleCrypto {
public static String encrypt(String seed, String cleartext)
throws Exception {
byte[] rawKey = getRawKey(seed.getBytes());
byte[] result = encrypt(rawKey, cleartext.getBytes());
return toHex(result);
}
public static String decrypt(String seed, String encrypted)
throws Exception {
byte[] rawKey = getRawKey(seed.getBytes());
byte[] enc = toByte(encrypted);
byte[] result = decrypt(rawKey, enc);
return new String(result);
}
private static byte[] getRawKey(byte[] seed) throws Exception {
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
sr.setSeed(seed);
kgen.init(128, sr); // 192 and 256 bits …Run Code Online (Sandbox Code Playgroud) encryption ×10
c# ×3
.net ×2
java ×2
aes ×1
android ×1
c ×1
cryptography ×1
cryptojs ×1
csv ×1
git ×1
obfuscation ×1
openssl ×1
php ×1
powershell ×1
process ×1
python-3.x ×1
winforms ×1