cryptography

How can I decrypt an encrypted MCRYPT_RIJNDAEL_256 value in C#, that was encrypted by mcrypt in PHP?

牧云@^-^@ 提交于 2019-12-21 07:04:29
问题 I am trying to read a Base64-Encoded value from a Database table managed on the Linux side. In that table there is a column called first_name. On the Linux side I can decrypt this easily by using the following command in PHP: $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, "patient_fn_salt", base64_decode("H6XmkH+VWvdD88THCliKJjLisGZIBk3CTNvyQMLnhpo="), MCRYPT_MODE_ECB); However I try as much as I can to duplicate this logic on the C# side and all I get is gibberish. My C# code is below, i hope

Demonstrate the use of RSA Public-key system to exchange messages that achieve confidentiality and integrity/authentication

我怕爱的太早我们不能终老 提交于 2019-12-21 06:57:19
问题 I'm trying to demonstrate the use of RSA Public-key system to exchange messages that achieve confidentiality and integrity/authentication. I am trying to encrypt a message on the client side and send this information to the server side to decrypt. The issue I am having is that my code is not decrypting. It is giving me the following error: javax.crypto.BadPaddingException: Data must start with zero at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:308) at sun.security.rsa.RSAPadding

RSA Encryption on iPhone

寵の児 提交于 2019-12-21 06:56:01
问题 According the discussion on http://forums.macrumors.com/showthread.php?t=551476 the code seen below would do for RSA encryption. The datatype of the key ("public") is SecKeyRef. I will not be using the keychain, though, as I'm only interested in encryption where the key is public and is no secret. Is it even possible to use the crypto API then? My current idea is to construct a SecKeyRef struct from my public key only and use the API. I don't know how the struct is declared, though. Does

Encryption and decryption using AES Algorithms

喜欢而已 提交于 2019-12-21 06:49:04
问题 I am making an encryption/decryption module for my app. I followed This Tutorial It is not giving any error and also not showing the output. Logfile 07-23 07:29:06.480: W/System.err(795): javax.crypto.BadPaddingException: pad block corrupted 07-23 07:29:06.629: W/System.err(795): at com.android.org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineDoFinal(BaseBlockCipher.java:710) 07-23 07:29:06.629: W/System.err(795): at javax.crypto.Cipher.doFinal(Cipher.java:1111) 07-23 07

JCE Unlimited Strength installed but AES 256 is not supported

时间秒杀一切 提交于 2019-12-21 06:44:49
问题 I have installed JCE Unlimited strength to JAVA_HOME\lib\security However, I'm still getting 128 for Cipher.getMaxAllowedKeyLength("AES") . I'm wondering if I have installed the JCE at the wrong place. I have Java installed in 2 places. C:\Program Files\Java\jre7 C:\Development\Java\jdk1.6.0_21 Can anyone tell me where is the correct place to install JCE Unlimited strength? Your help is much appreciated. my code: KeyGenerator generator = KeyGenerator.getInstance("AES"); generator.init(256);

Different bytes are returned when decrypt file's content

杀马特。学长 韩版系。学妹 提交于 2019-12-21 06:40:10
问题 So I decided to expand my knowledge in cryptography, but I have the following code to encrypt a file's content and later decrypt it. My problem is, when I decrypt the content and compare the two byte array what I have (original and decrypted content) I have two different arrays in length and even in content. Could any of you spot what could be the wrong in my code? The original content is a base 64 decoded byte array. public class KeyStoreHelper { public static byte[] decryptAES

Is it RC4 or ARCFOUR? InvalidKeyException when using SecretKeySpec?

拥有回忆 提交于 2019-12-21 06:39:12
问题 I tried running my application on my pc, but I keep getting this thing. Is it possible that I'm missing some libraries? fabsam.crypto.CryptoException: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec at fabsam.crypto.RC4Decoder.decode(RC4Decoder.java:37) ~[bin/:na] ... (skipped my projects stack trace) at java.lang.Thread.run(Thread.java:662) [na:1.6.0_25] Caused by: java.security.InvalidKeyException: No installed provider supports

javax.crypto.BadPaddingException: Decryption error

好久不见. 提交于 2019-12-21 06:37:50
问题 Here is the error I have got when run my Encode & Decode Class. javax.crypto.BadPaddingException: Decryption error at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:380) at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:291) at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:365) at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:391) at javax.crypto.Cipher.doFinal(Cipher.java:2087) at RSAEncDecDemo.decryptData(RSAEncDecDemo.java:64) at RSAEncDecDemo.main

Random access of encrypted data AES GCM mode

女生的网名这么多〃 提交于 2019-12-21 06:29:49
问题 There is a very good example for random access AES CTR mode and it works: Random access InputStream using AES CTR mode in android private static final int AES_BLOCK_SIZE = 16; private static IvParameterSpec calculateIVForOffset(final IvParameterSpec iv, final long blockOffset) { final BigInteger ivBI = new BigInteger(1, iv.getIV()); final BigInteger ivForOffsetBI = ivBI.add(BigInteger.valueOf(blockOffset / AES_BLOCK_SIZE)); final byte[] ivForOffsetBA = ivForOffsetBI.toByteArray(); final

How to programmatically generate a self signed certificate?

[亡魂溺海] 提交于 2019-12-21 06:29:46
问题 I have a RSA public key (2048 bit) generated by a HSM, that key has been saved in a file (with a size of 256 byte) and is encoded as DER. Is it possibile to programmatically create a self-signed certificate using JDK API (without BouncyCastle) starting from that file? I'm stuck with the first step, because I'm trying to load the key file to create a PublicKey object: import java.io.FileInputStream; import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec