encryption

IllegalBlockSize Exception When Doing RSA on bytes of Strings

帅比萌擦擦* 提交于 2020-01-31 20:04:09
问题 I am trying to write RSA encryption and decryption classes in Java for a server where the client will be passing strings back and forth. I have the following code for the classes: public class RSAEncryption { public static final String KEYGENALGORITHM = "RSA"; public static final String ALGORITHM = "RSA/ECB/PKCS1Padding"; public static KeyPairContainer generateKey() { KeyPairGenerator keyGen; KeyPair key; try { keyGen = KeyPairGenerator.getInstance(KEYGENALGORITHM); keyGen.initialize(1024);

Android Encryption RSA InvalidKeyException

天涯浪子 提交于 2020-01-31 06:18:53
问题 Dears, I need help to understand why decryptString doesn't work and throw "java.security.InvalidKeyException: Need RSA private or public key". When call encrypt method, i use public key by the private key/certificate. Thanks for any help! public class KeysHandler { /*** * Generate and store in AndroidKeyStore a security KeyPair keys. * @param alias - Alias to create the key. * @return KeyPair object with: private and public key. */ public static KeyPair generateKeyPair(String alias) { KeyPair

Android Encryption RSA InvalidKeyException

扶醉桌前 提交于 2020-01-31 06:15:29
问题 Dears, I need help to understand why decryptString doesn't work and throw "java.security.InvalidKeyException: Need RSA private or public key". When call encrypt method, i use public key by the private key/certificate. Thanks for any help! public class KeysHandler { /*** * Generate and store in AndroidKeyStore a security KeyPair keys. * @param alias - Alias to create the key. * @return KeyPair object with: private and public key. */ public static KeyPair generateKeyPair(String alias) { KeyPair

Storing public key in sharedPreferences, and Retrieving it

谁说胖子不能爱 提交于 2020-01-31 04:03:09
问题 I am trying to use encrypt data using RSA. So far everything is fine. I can generate Private-Public keys, I can encrypt and Decrypt string successfully. Now i want stored Public key in SharedPreference. I can store it as string. I can retrieve it as string. I need to convert it to Key, to pass to cipher. Conversion from String to original format is not happening. This is what i tried KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); //generate key using RSA KeyPair

Can't check signature: public key not found

孤街醉人 提交于 2020-01-30 14:27:09
问题 I try to decrypt file using following command: gpg --output file.txt --decrypt file.pgp File is decrypted successfully but i get an error: "gpg: Can't check signature: public key not found" Any idea, why I get this error? 回答1: You get that error because you don't have the public key of the person who signed the message. gpg should have given you a message containing the ID of the key that was used to sign it. Obtain the public key from the person who encrypted the file and import it into your

XOR - Explaining of 3 lines [closed]

邮差的信 提交于 2020-01-30 13:34:20
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . We are doing a school project where we need to explain code line by line. We need to explain the following 3 lines: // TODO: This is where the magic of XOR is happening. Are you able to explain what is going on? for (int i = 0; i < rawString.length(); i++) { thisIsEncrypted.append((char) (rawString

XOR - Explaining of 3 lines [closed]

▼魔方 西西 提交于 2020-01-30 13:33:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago . We are doing a school project where we need to explain code line by line. We need to explain the following 3 lines: // TODO: This is where the magic of XOR is happening. Are you able to explain what is going on? for (int i = 0; i < rawString.length(); i++) { thisIsEncrypted.append((char) (rawString

Java Out of Memory Error during Encryption

痴心易碎 提交于 2020-01-30 10:58:59
问题 I am using AES to encrypt files. The problem first came when i tried to encrypt a large file. So i did some reading online and figured that i need to use a buffer and only encrypt bytes of data at a time. I divided my plaintext into chunks of 8192 bytes of data and then applied the encryption operation on each of these chunks but I am still getting the out of memory error. public static File encrypt(File f, byte[] key) throws Exception { System.out.println("Starting Encryption"); byte[]

Java Out of Memory Error during Encryption

放肆的年华 提交于 2020-01-30 10:55:18
问题 I am using AES to encrypt files. The problem first came when i tried to encrypt a large file. So i did some reading online and figured that i need to use a buffer and only encrypt bytes of data at a time. I divided my plaintext into chunks of 8192 bytes of data and then applied the encryption operation on each of these chunks but I am still getting the out of memory error. public static File encrypt(File f, byte[] key) throws Exception { System.out.println("Starting Encryption"); byte[]

Issue with encrypt and decrypt a word docx file in php

孤街浪徒 提交于 2020-01-30 06:58:04
问题 I tried to use php mcrypt TripleDES for encryption for docx format files. When i tried to decrypt the file, i am getting the error as follows. The Office Open XML file file_name cannot be opened because there are problems with the contents. Here is the below code function Encrypt($source,$key,$iv) { $cipher = mcrypt_module_open(MCRYPT_3DES, '', 'cbc', ''); mcrypt_generic_init($cipher, $key, $iv); $result = mcrypt_generic($cipher, $source); mcrypt_generic_deinit($cipher); return $result; }