encryption

AES encryption, what are public and private keys?

给你一囗甜甜゛ 提交于 2020-01-09 12:19:06
问题 In AES encryption (.net framework), how are the public and private keys used? Are the public and private keys combined to form a full key, and then the algorithm uses the public + private key to encrypt the data? (simplified keys used below for example purposes) e.g. public key = 12345 private key = 67890 so the key used when generating the encryption result is: 1234567890 回答1: As others have said, AES is a symmetric algorithm (private-key cryptography). This involves a single key which is a

CipherInputStream and CipherOutputStream are not generating files

你。 提交于 2020-01-09 10:32:52
问题 I have the following code. However the files b.xlsx and c.xlsx are of 0 bytes. Why is CipherOuputSteam not working? public static void main(String[] args) throws Exception { KeyPair keys = KeyPairGenerator.getInstance("RSA").generateKeyPair(); Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, keys.getPublic()); FileInputStream fis; FileOutputStream fos; CipherOutputStream cos; fis = new FileInputStream("C:/temp/a.xlsx"); fos = new FileOutputStream("C:/temp/b.xlsx");

AES encryption in javascript and decrypting in java

℡╲_俬逩灬. 提交于 2020-01-09 10:32:42
问题 I have an excisting webservice which encrypts and decrypts with AES, now i have to encrypt in the same way as java but in javascript. I have read all the topics about doing this in javascript but haven't found any helpfull solution. Javascript always encrypts in a different way and i can't find why. This is the excisting java code : public static String encrypt(String data) throws Exception { byte[] keyValue = encryptionKey.getBytes(); Key key = new SecretKeySpec(keyValue, "AES"); Cipher c =

Java: StreamCorruptedException occur when Decrypt object with DES

牧云@^-^@ 提交于 2020-01-09 10:32:33
问题 I have two method for Encrypt-save and decrypt-load Object from file in Android Internal Storage. Encrypt and save process is done without any problem, but when I want to load the object StreamCorruptedException occurs in inputStream = new ObjectInputStream(cipherInputStream); I searched SO more and more but I did't find a solution for my problem. all other solutions are for socket life or like this. my code is below: private static byte[] iv = { (byte) 0xB1, (byte) 0x15, (byte) 0xB5, (byte)

Java/JCE: Decrypting “long” message encrypted with RSA

半腔热情 提交于 2020-01-09 10:12:49
问题 I've got a message contained in an byte[], encrypted with "RSA/ECB/PKCS1Padding". To decrypt it I create a Cipher c and initiate it with c = Cipher.getInstance("RSA/ECB/PKCS1Padding"); Untill now I have only decrypted small messages, using the doFinal() method, returning an byte[] with the decrypted bytes. c.init(Cipher.DECRYPT_MODE, privateKey); byte[] decryptetBytes = c.doFinal(encryptedBytes); But in this case the data is bigger (approx 500 Bytes), and the doFinal() -method throws an

Java/JCE: Decrypting “long” message encrypted with RSA

ⅰ亾dé卋堺 提交于 2020-01-09 10:11:32
问题 I've got a message contained in an byte[], encrypted with "RSA/ECB/PKCS1Padding". To decrypt it I create a Cipher c and initiate it with c = Cipher.getInstance("RSA/ECB/PKCS1Padding"); Untill now I have only decrypted small messages, using the doFinal() method, returning an byte[] with the decrypted bytes. c.init(Cipher.DECRYPT_MODE, privateKey); byte[] decryptetBytes = c.doFinal(encryptedBytes); But in this case the data is bigger (approx 500 Bytes), and the doFinal() -method throws an

What is the difference between the different padding types on iOS?

删除回忆录丶 提交于 2020-01-09 10:06:41
问题 On iOS, the Certificate, Key, and Trust Services API contains the following padding types: kSecPaddingNone kSecPaddingPKCS1 kSecPaddingPKCS1MD2 kSecPaddingPKCS1MD5 kSecPaddingPKCS1SHA1 A user on the Apple CDSA mailing list says that "kSecPaddingPKCS1 [...] is the same as PKCS #1 1.5". The Certificate, Key, and Trust Services Reference annotates the latter three padding types ( kSecPaddingPKCS1MD2 , kSecPaddingPKCS1MD5 , and kSecPaddingPKCS1SAH ) with "Standard ASN.1 padding will be done, as

What is the difference between the different padding types on iOS?

╄→尐↘猪︶ㄣ 提交于 2020-01-09 10:05:18
问题 On iOS, the Certificate, Key, and Trust Services API contains the following padding types: kSecPaddingNone kSecPaddingPKCS1 kSecPaddingPKCS1MD2 kSecPaddingPKCS1MD5 kSecPaddingPKCS1SHA1 A user on the Apple CDSA mailing list says that "kSecPaddingPKCS1 [...] is the same as PKCS #1 1.5". The Certificate, Key, and Trust Services Reference annotates the latter three padding types ( kSecPaddingPKCS1MD2 , kSecPaddingPKCS1MD5 , and kSecPaddingPKCS1SAH ) with "Standard ASN.1 padding will be done, as

hash() vs. crypt() function comparison

痴心易碎 提交于 2020-01-09 10:04:54
问题 I'm currently implementing a login system. I want to store the password and the salt in a database. Now I found out that there is a hash() and a crypt() function which seems to do the same (valid for SHA512). hash() is newer and seems to support more hashing alogrithms than crypt() . Or there any other differences I should know/care about? Edit: function generatePasswordHash($password){ $salt = base64_encode(mcrypt_create_iv(8)); $calculatedPasswordHash = crypt($password, '$1$' . $salt . '$')

MCrypt rijndael-128 to OpenSSL aes-128-ecb conversion

為{幸葍}努か 提交于 2020-01-08 21:39:50
问题 Since Mcrypt is deprecated, I want to use OpenSSL instead in my code since we already using php 7.0.17 in our server and there's no tell when they upgrade it. Some third party API (hosted on PHP 5.x probably and using mcrypt ), is taking encrypted data. They've provided methods which they are using to encrypt/decrypt strings. Here are they $secret = 'a0a7e7997b6d5fcd55f4b5c32611b87c' ; public function encrypt128($str) { $block = mcrypt_get_block_size("rijndael_128", "ecb"); $pad = $block -