public-key-encryption

Flexiprovider elliptic curve public key from byte array

徘徊边缘 提交于 2019-12-12 05:48:22
问题 I'm using the FlexiEC provider to generate an elliptic curve public key. Then I convert the key into a byte array. After that I want to get an instance of this public key from this byte array. Whenever I do this I get an exception. The code is as follows: import java.security.KeyPair; import java.security.KeyFactory; import java.security.KeyPairGenerator; import java.security.PrivateKey; import java.security.PublicKey; import java.security.SecureRandom; import java.security.Security; import

openssl phishing : V claims to be A

怎甘沉沦 提交于 2019-12-12 03:07:33
问题 there are several components of my application, needs their communication secure in the sense Origin Verified. these components cannot share a common secret. So I have to opt for asymmetric key encryption. assuming I've two components A and B A sends some data F to B and B has to verify that it really came from A A generates digest H of F with its private Key A attaches A_pub , H to its request Parameters, sends F and declares origin/sender as A B verifies the digest H with the A_pub provided

What is the best way to encode string by public-key in python

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:09:38
问题 Is there any way to encode string by public-key? I found two packages, pycrypto and m2crypto. But I can not find how to use them. 回答1: To encode a string using public key: #!/usr/bin/env python from M2Crypto import RSA, X509 x509 = X509.load_cert("recipient_cert.pem") rsa = x509.get_pubkey().get_rsa() print rsa.public_encrypt("your string to encrypt", RSA.pkcs1_oaep_padding) 来源: https://stackoverflow.com/questions/7563732/what-is-the-best-way-to-encode-string-by-public-key-in-python

Encrypting using node-forge and decrypting using python with RSA-OAEP

喜夏-厌秋 提交于 2019-12-12 01:45:25
问题 I have following code to encrypt in Javascript: var rsa = forge.pki.rsa; var keypair = rsa.generateKeyPair({bits: 2048, e: 0x10001}); var ciphertext = keypair.publicKey.encrypt("zz xx yy", 'RSA-OAEP', { md: forge.md.sha256.create(), mgf1: { md: forge.md.sha1.create() } }); keypair.privateKey.decrypt(ciphertext, 'RSA-OAEP', { md: forge.md.sha256.create(), mgf1: { md: forge.md.sha1.create() } }); "zz xx yy" I exported public and private keys using forge.pki.privateKeyToPem(keypair.privateKey) /

Determining if a request came from an iPhone app

风流意气都作罢 提交于 2019-12-11 23:32:45
问题 I have an iPhone app that communicates with a server (both of which I own and wrote the code for). I need to way to determine if a request on my server came from an iPhone (or any mobile device running the app I wrote for that matter). Basically, I only want to allow apps that I wrote to communicate with the server and need a way to verify that. Since I'm writing the apps, I can modify the headers and what not any way I need to. I read up a little on Public Key Encryption, but I don't think

String to PublicKey using Diffie-Hellman algorithm

元气小坏坏 提交于 2019-12-11 19:44:40
问题 I have a Public key string (128 bytes byte to hex processed) given by my client. I need to generate shared key using the private key and Public key given by client. I'm getting below exception while converting the String to Public key. I tried decoding/encoding the bytes, no improvement. I have the following code. // This is a sample key. private static final String PUB_KEY = "0DC1B7102DE3F6785A284ABFCA1822A6B59C947B5F2FAAE" +

Output of openssl_public_encrypt() and openssl_private_encrypt()

前提是你 提交于 2019-12-11 18:23:34
问题 I would like to know few things What is output of openssl_public_encrypt() and openssl_private_encrypt() functions? Output of above functions (Encrypted data), will that be web-safe? How can I transfer generated encrypted data between websites? 回答1: openssl_public_encrypt() encrypts a message with a public key so that only the corresponding private key can decrypt it. This is used for protecting information against being seen by people who shouldn't. openssl_private_encrypt() encrypts a

How to encrypt text using RSA algo

China☆狼群 提交于 2019-12-11 17:46:01
问题 I need to encrypt texts written in a file and decrypt it, without using the PyCrypto library. The file will contain string type data. Now I want to convert the strings to int numbers so that I can apply the RSA keys on the integer values. But I did not find any tutorial on how to convert texts into int. How to convert the strings into its integer value and Is there any better way of doing this? then how? Thank you. 回答1: I too had this project, and I did this: First what you will need is to

java.security.InvalidKeyException: invalid key format while generating public, private key from PEM file

喜夏-厌秋 提交于 2019-12-11 13:17:42
问题 I have gone through many similar threads but no luck!! I want to generate public and private keys using a PEM file. Following is the code I am using for the same: String pemFileNme = "C:\\Users\\amitmm\\Desktop\\clean\\key.pem"; File pubKeyFile = new File(pemFileNme); File privKeyFile = new File(pemFileNme); // read public key DER file DataInputStream dis = new DataInputStream(new FileInputStream(pubKeyFile)); byte[] pubKeyBytes = new byte[(int)pubKeyFile.length()]; dis.readFully(pubKeyBytes)

java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException: Detect premature EOF

寵の児 提交于 2019-12-11 12:43:50
问题 i have this code : // Turn the encoded key into a real RSA public key. // Public keys are encoded in X.509. X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); PublicKey publicKey = keyFactory.generatePublic(keySpec); error: java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException: Detect premature EOF where is the problem? 回答1: public static PublicKey getPublicKey(String key) throws Exception