encryption-symmetric

Illegal Block Size Exception Input length must be multiple of 16 when decrypting with padded cipher

試著忘記壹切 提交于 2019-11-29 14:26:34
问题 In my application I am encrypting and decrypting data using secretKey. For that I am using AES algorithm. But I am getting exception in decrypt, one value out of three already encrypted values using secret key. Exception is: Illegal Block Size Exception Input length must be multiple of 16 when decrypting with padded cipher. Below is my code: Function to encyrpt value public static String symmetricEncrypt(String text, String secretKey) { BASE64Decoder decoder = new BASE64Decoder(); byte[] raw;

Encrypting Crypt field using Classic ASP for SagePay Form Integration

丶灬走出姿态 提交于 2019-11-29 12:04:50
I always get the same error 3045: The Currency field is missing, when posting this form: <form name="frmPay" action="https://test.sagepay.com/gateway/service/vspform-register.vsp" method="POST"> <input type="text" name="VPSProtocol" value="3.00" /> <input type="text" name="TxType" value="PAYMENT" /> <input type="text" name="Vendor" value="myvendor" /> Crypt:<textarea rows="10" cols="200" name="Crypt"><%=Crypt%></textarea> <input type="submit" value="Send" /> </form> I think the error is in the encryption Could someone send encryption routine for classic ASP? Lankymart UPDATE (19-Nov-2014): A

Deriving a secret from a master key using JCE/JCA

纵饮孤独 提交于 2019-11-28 20:57:13
Can some point me in the right direction? I'd like to use JCE/JCA to derive a new key from a master secret key, How can I achieve this? Regards. The JCA provides standard password-based key derivation functions like PBKDF2 defined in PKCS#5 v2.0 and RFC 2898 . This algorithm creates some random material from a master secret (a password) in order to generate a key suitable for a given cipher. public byte[] deriveKey(String password, byte[] salt, int keyLen) { SecretKeyFactory kf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); KeySpec specs = new PBEKeySpec(password.toCharArray(), salt,

Hybrid cryptosystem implementation in .net. Error Specified key is not a valid size for this algorithm

旧时模样 提交于 2019-11-28 11:55:39
问题 I am trying to implement hybrid cryptosystem as mentioned in https://en.wikipedia.org/wiki/Hybrid_cryptosystem At the moment I have implemented following algorithm private void button1_Click(object sender, EventArgs e) { CspParameters cspParams = new CspParameters { ProviderType = 1 }; RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(1024, cspParams); string publicKey = Convert.ToBase64String(rsaProvider.ExportCspBlob(false)); string privateKey = Convert.ToBase64String

PyCrypto problem using AES+CTR

冷暖自知 提交于 2019-11-28 11:07:52
I'm writing a piece of code to encrypt a text using symmetric encryption. But it's not coming back with the right result... from Crypto.Cipher import AES import os crypto = AES.new(os.urandom(32), AES.MODE_CTR, counter = lambda : os.urandom(16)) encrypted = crypto.encrypt("aaaaaaaaaaaaaaaa") print crypto.decrypt(encrypted) Here, the decrypted text is different from the original. I don't really understand much about cryptography so please bear with me. I understand the CTR mode requires a "counter" function to supply a random counter each time, but why does it need it to be 16 bytes when my key

Symmetric Encryption (AES): Is saving the IV and Salt alongside the encrypted data safe and proper?

[亡魂溺海] 提交于 2019-11-28 09:00:45
I am trying to make sense of how to handle and manage an initilization vector and salt (when applicable) when encrypting and decrypting data using a symmetric encryption algorithm, in this case AES. I have deduced from different SO threads and various other websites that neither the IV or salt need to be secret, only unique in order to defend against cryptanalytic attacks such as a brute-force attack. With this in mind I figured that it would be viable to store my pseudo random IV with the encrypted data. I am asking if the method I am using is proper and furthermore, should I be treating my

Simple Encryption in Ruby without external gems

為{幸葍}努か 提交于 2019-11-28 05:56:14
I need a simple encryption for some text strings. I want to create coupon codes and make them look cool so subsequently created code should look very different. (And besides looking cool, it shouldn't be easy to guess a code.) But I want to be able to decrypt them again. So the algorithm must be reversible. I alread tried some stuff with moving bits around so they look kind of random already. But two subsequent codes (just one bit different) of course look very similar. Any suggestions? I would like to do that without using external gems. Philip Joshua Cheek You could use OpenSSL::Cypher # for

Encrypting Crypt field using Classic ASP for SagePay Form Integration

一笑奈何 提交于 2019-11-28 05:47:31
问题 I always get the same error 3045: The Currency field is missing, when posting this form: <form name="frmPay" action="https://test.sagepay.com/gateway/service/vspform-register.vsp" method="POST"> <input type="text" name="VPSProtocol" value="3.00" /> <input type="text" name="TxType" value="PAYMENT" /> <input type="text" name="Vendor" value="myvendor" /> Crypt:<textarea rows="10" cols="200" name="Crypt"><%=Crypt%></textarea> <input type="submit" value="Send" /> </form> I think the error is in

Deriving a secret from a master key using JCE/JCA

两盒软妹~` 提交于 2019-11-27 13:21:05
问题 Can some point me in the right direction? I'd like to use JCE/JCA to derive a new key from a master secret key, How can I achieve this? Regards. 回答1: The JCA provides standard password-based key derivation functions like PBKDF2 defined in PKCS#5 v2.0 and RFC 2898. This algorithm creates some random material from a master secret (a password) in order to generate a key suitable for a given cipher. public byte[] deriveKey(String password, byte[] salt, int keyLen) { SecretKeyFactory kf =

Differences Between Rijndael and AES

时光总嘲笑我的痴心妄想 提交于 2019-11-27 07:58:28
I'm investigating encryption algorithms - can someone give me a quick rundown of the differences between Rijndael and AES? Brian Campbell AES is a United States federal standard, FIPS 197 , which is a subset of Rijndael : AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas Rijndael can be specified with block and key sizes in any multiple of 32 bits, with a minimum of 128 bits and a maximum of 256 bits. From Advanced Encryption Standard on Wikipedia . Strictly speaking, the Advanced Encryption Standard (AES) is not an algorithm. AES is a specification