private-key

How can I encrypt with a RSA private key in python?

荒凉一梦 提交于 2020-05-25 07:49:44
问题 Is it possible to encrypt a message with a private key in python using pycryptodome or any other library? I know that you are not supposed to encrypt with the private key and decrypt with the public key, but my purpose is to encrypt with the private one so the receiver could be sure that the message was send by the real author. More than secure encryption I'm looking for some kind of obfuscation. I want to do an app where the message is public but it can only be seen if you have the public

Setting a custom path for git private SSH key on linux

和自甴很熟 提交于 2020-05-24 08:24:05
问题 I'm trying to setup a git client on linux. I uploaded my private key to the machine, and I understand that I should put it in ~/.ssh, but I don't have access to that folder. How can I tell git to look for the private key somewhere else? 回答1: One option is to use ssh-agent and provide a file name to ssh-add . For example: $ ssh-agent /bin/bash $ ssh-add ~/mykeys/id_rsa 回答2: You can achieve that using a ssh config file. First create a file inside your ~/.ssh folder named config , you can use

Derive EC public key from private key string in native Java for curve secp256k1

徘徊边缘 提交于 2020-04-30 07:09:07
问题 I need to derive an EC Public Key from an EC private key string without the "help" of any third party library. The Private key is externally produced and provided and I need to get the Public Key to generate a Bitcoin address. As my project is working "offline" I do not need a library like Bouncy Castle for any other purpose, so I would like to eliminate it. The following program is fully working and shows the (very short) example when working with Bouncy Castle to get a solution. The second

Create X509Certificate2 from PEM file in .NET Core

大城市里の小女人 提交于 2020-04-09 17:54:42
问题 I want to create a X509Certificate2 object based on a PEM file. The problem is setting the PrivateKey property of X509Certificate2. I read X509Certificate2.CreateFromCertFile() on .NET Core and then used var rsa = new RSACryptoServiceProvider(); rsa.ImportCspBlob(pvk); Where pvk is the byte array of the private key (read from GetBytesFromPEM as shown here how to get private key from PEM file?), to set the private key, but then I get an Internal.Cryptography.CryptoThrowHelper

Decrypt passphrase protected PEM containing private key

情到浓时终转凉″ 提交于 2020-03-21 16:09:58
问题 I have the following method that creates an Encrypted Private Key using Bouncy Castle for C#: public string GetPrivateKey(AsymmetricCipherKeyPair keyPair, string password) { var generator = new Pkcs8Generator(keyPair.Private, Pkcs8Generator.PbeSha1_3DES); generator.IterationCount = 4; generator.Password = password.ToCharArray(); var pem = generator.Generate(); TextWriter textWriter = new StringWriter(); PemWriter pemWriter = new PemWriter(textWriter); pemWriter.WriteObject(pem); pemWriter

Decrypt passphrase protected PEM containing private key

半腔热情 提交于 2020-03-21 16:08:52
问题 I have the following method that creates an Encrypted Private Key using Bouncy Castle for C#: public string GetPrivateKey(AsymmetricCipherKeyPair keyPair, string password) { var generator = new Pkcs8Generator(keyPair.Private, Pkcs8Generator.PbeSha1_3DES); generator.IterationCount = 4; generator.Password = password.ToCharArray(); var pem = generator.Generate(); TextWriter textWriter = new StringWriter(); PemWriter pemWriter = new PemWriter(textWriter); pemWriter.WriteObject(pem); pemWriter

Convert .pem key file to .ppk in Windows automatically/script/command line

ぃ、小莉子 提交于 2020-02-28 08:42:22
问题 I'm using Vagrant to create VMs on a Windows host, to which I would like to connect with PuTTY. Vagrant creates an RSA private key in the .pem format. PuTTY needs a key in the .ppk format to create a connection. I would like to convert the .pem to .ppk automatically when creating the vagrant VM. The question of how to convert .pem to .ppk has been asked and answered lots of times, but on Windows all those answers involve clicking through the puttygen GUI. It seems that on Linux, puttygen can

How to change a .p12 file to .key file

断了今生、忘了曾经 提交于 2020-02-26 09:06:02
问题 I have a .p12 file, I can also transfer it to a .pem file, but how to transfer it as a .key file? 回答1: openssl pkcs12 -in out.p12 -nodes -out private.key -nocerts openssl will ask you for a password, then store the unencrypted private key into the file private.key Documentation: https://www.openssl.org/docs/man1.1.0/apps/pkcs12.html 来源: https://stackoverflow.com/questions/16075846/how-to-change-a-p12-file-to-key-file

How to change a .p12 file to .key file

旧城冷巷雨未停 提交于 2020-02-26 09:05:11
问题 I have a .p12 file, I can also transfer it to a .pem file, but how to transfer it as a .key file? 回答1: openssl pkcs12 -in out.p12 -nodes -out private.key -nocerts openssl will ask you for a password, then store the unencrypted private key into the file private.key Documentation: https://www.openssl.org/docs/man1.1.0/apps/pkcs12.html 来源: https://stackoverflow.com/questions/16075846/how-to-change-a-p12-file-to-key-file

Convert private key to PKCS#8 format in java

不打扰是莪最后的温柔 提交于 2020-02-04 05:38:06
问题 I'm trying to get certificates and private keys from windows certificate store using MSCAPI provider, then i need to store them in a Java Keystore object, but i'm facing a problem of private keys format, the error says: java.security.KeyStoreException: Cannot get key bytes, not PKCS#8 encoded Here's my code: SunMSCAPI providerMSCAPI = new SunMSCAPI(); Security.addProvider(providerMSCAPI); KeyStore ks = KeyStore.getInstance("Windows-MY"); ks.load(null, null); PrivateKey privateKey = null;