encryption-asymmetric

Java asymmetric encryption: preferred way to store public/private keys

白昼怎懂夜的黑 提交于 2019-12-02 16:00:25
This code generates a pair of public/private keys: KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(1024); KeyPair keypair = keyGen.genKeyPair(); PrivateKey privateKey = keypair.getPrivate(); PublicKey publicKey = keypair.getPublic(); What I'd like to know is how do you usually store the public key: Option 1: store the bytes byte[] privateKeyBytes = privateKey.getEncoded(); byte[] publicKeyBytes = publicKey.getEncoded(); // ... write to file // convert bytes back to public/private keys KeyFactory keyFactory = KeyFactory.getInstance("RSA"); EncodedKeySpec

Cannot Decrypt RSA encrypted Key

╄→尐↘猪︶ㄣ 提交于 2019-12-02 01:16:35
问题 Long story short, I'm using DES and I'm encrypting a password using RSA for key exchange, the password does not exceed 16 characters the problem is when i encrypt the key, the encrypted size becomes too big for me to decrypt here's my rsa encrypt and decrypt code: Encrypt:--i've been trying the localpwd as "asd" byte[] plaintext = utf8.GetBytes(localpwd); byte[] ciphertext = rsaservice.Encrypt(plaintext, false); string cipherresult = Convert.ToBase64String(ciphertext); then i print the

Cannot Decrypt RSA encrypted Key

你说的曾经没有我的故事 提交于 2019-12-01 22:32:56
Long story short, I'm using DES and I'm encrypting a password using RSA for key exchange, the password does not exceed 16 characters the problem is when i encrypt the key, the encrypted size becomes too big for me to decrypt here's my rsa encrypt and decrypt code: Encrypt:--i've been trying the localpwd as "asd" byte[] plaintext = utf8.GetBytes(localpwd); byte[] ciphertext = rsaservice.Encrypt(plaintext, false); string cipherresult = Convert.ToBase64String(ciphertext); then i print the encrypted key on the textbox and try decrypting byte[] ciphertext = utf8.GetBytes(filetest.Text); byte[]

How to use nonces in asymmetric encryption (libsodium)?

微笑、不失礼 提交于 2019-12-01 04:16:38
I am writing an app where users can communicate between devices with end to end encryption. For this I use the libsodium encryption library. The asymmetric encryption function, crypto_box(...) requires a nonce as one of the arguments. I am a bit confused about how to handle nonces. Does every message to one person need to be encrypted using different nonces? This does not seem right since I would have to store the used nonces on a server with public access where an attacker could just use one of the used nonces again. Is it enough that all messages sent from A to B have different nonces or can

How to use nonces in asymmetric encryption (libsodium)?

…衆ロ難τιáo~ 提交于 2019-12-01 01:54:45
问题 I am writing an app where users can communicate between devices with end to end encryption. For this I use the libsodium encryption library. The asymmetric encryption function, crypto_box(...) requires a nonce as one of the arguments. I am a bit confused about how to handle nonces. Does every message to one person need to be encrypted using different nonces? This does not seem right since I would have to store the used nonces on a server with public access where an attacker could just use one

Flexiprovider - How to encrypt/de with formatted keypair

寵の児 提交于 2019-11-30 17:07:28
Im using flexiprovider to encrypt/de with asymmetric algorithm based on Elliptic Curve following this tutorial . With a little modification, i'm gonna convert the public and the private key into Base64 for personal purpose (like storing into the database or text file). I'm also looking at this question and the answer is refer to this thread . But my code are running for dekstop not in android device, android and dekstop version in java i think is a really big difference (just for clean up my question information). Ok, in my code when im going to create the formatted public key from a generated

Javascript asymmetric encryption and authentication

北城余情 提交于 2019-11-30 15:55:34
Some of the guys here are developing an application which incorporates some 'secure areas' accessible by logging in. In the past, the login form and subsequent 'secure' pages were all plain text transmitted over http, as it's an application that goes out for use on shared servers where there is little chance of being able to use SSL (think WordPress and the like). Most people just shrugged their shoulders as that's all they expected - it's hardly a national bank. We are now thinking of writing the next version using a JavaScript front end, with the advantage of loading all the images & CSS

BadPaddingException: invalid ciphertext

亡梦爱人 提交于 2019-11-30 10:39:21
I would like some help as this is my first time in coding cryptography code. The encryption code appears to be working correctly, but the decryption throws an error. The error I get is: de.flexiprovider.api.exceptions.BadPaddingException: invalid ciphertext in the decrypt function towards the end of the code, which is marked as a comment // ERROR THROWN HERE! .............................. I have included all the imports, please excuse this, as thought it maybe relevant to the issue. Any help as to what I am doing wrong will be greatly appreciated, thanks very much. Code: import java.io

Encrypting Certificate

淺唱寂寞╮ 提交于 2019-11-30 10:39:21
I am getting issue on Microsoft internet explorer certificate while encrypt with private key and decrypt with public key having issue 1) Encrypt working file public String encryption(String inputData, String key, String certificate) // Certificate is nothing but aliase name { String encriptData = null; String verify = checkForCertificateConfig(); if (!verify.equals("OK")) { return verify; } System.out.println("ENCRYPTION INPUTDATA : " + inputData); System.out.println("ENCRYPTION KEY : " + key); System.out.println("ENCRYPTION CERTIFICATE : " + certificate); try { if (key.equalsIgnoreCase(

Cracking short RSA keys

岁酱吖の 提交于 2019-11-30 10:05:33
问题 Given the following RSA keys, how does one go about determining what the values of p and q are? Public Key: (10142789312725007, 5) Private Key: (10142789312725007, 8114231289041741) 回答1: Your teacher gave you: Public Key: (10142789312725007, 5) which means n = 10142789312725007 e = 5 where n is the modulus and e is the public exponent. In addition, you're given Private Key: (10142789312725007, 8114231289041741) meaning that d = 8114231289041741 where d is the decryption exponent that should