rijndael

Decrypting data with openssl commandline tool

那年仲夏 提交于 2019-12-06 08:36:20
I have to following code and as far as I know it is correct, but it does not work. I am trying to encode data with PHP's Mcrpyt and then decode it with the openssl commandline tool. This is my PHP code: /* * Convert a normal ascii string to a hexadecimal string. * Complement of hexToString(). */ function stringToHex($str) { $hex_str = ""; for ($i = 0; $i < strlen($str); ++$i) { $hex_str .= sprintf("%02X", ord($str[$i])); } return $hex_str; } $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_DEV_RANDOM); $block_size = mcrypt_get_block_size("rijndael-128",

Password encryption/decryption between classic asp and ASP.NET

别说谁变了你拦得住时间么 提交于 2019-12-06 01:28:18
I have 2 websites: one written in classic asp and another written in ASP.NET (1.1 framework). Both applications use a login mechanism to validate user credentials based on a shared database table. Up to now passwords are stored in a 1-way MD5 hash, meaning people must be given a new generated password if they lose the old one. I now want to change this and make the passwords decryptable. I found this Rijndael code to use with classic asp: http://www.frez.co.uk/freecode.htm#rijndael But I cannot find the same solution for ASP.NET. I tried this, but it gives me different encryption and

Rijndael 256 encryption: Java and .NET do not match

梦想与她 提交于 2019-12-06 00:59:59
问题 I need to translate a powershell script with Rijandael encryption to Java. Here is the source powershell code: [Reflection.Assembly]::LoadWithPartialName("System.Security") Add-Type -AssemblyName System.Web $sKy = "bbee9a3e8e44e28edb4539186d182aaa" $sIV = "131a68dc13160766f37dc931d7e518aa" $myRijndael = New-Object System.Security.Cryptography.RijndaelManaged $myRijndael.KeySize = 256 $myRijndael.BlockSize = 256 $myRijndael.Mode = [System.Security.Cryptography.CipherMode]::CBC $myRijndael

Perl & Ruby exchange AES encrypted information

こ雲淡風輕ζ 提交于 2019-12-05 19:07:28
What is the equivalent to Crypt::CBC in Perl for Ruby? Note: This problem similar to PHP/Perl at stackoverflow:655691 . Perl Version use Crypt::CBC; use MIME::Base64::Perl; my $cipher = Crypt::CBC->new( -key => "95A8EE8E89979B9EFDCBC6EB9797528D", -keysize => 32, -cipher => "Crypt::OpenSSL::AES" ); $encypted = $cipher->encrypt("ABCDEFGH12345678"); $base64 = encode_base64($encypted); print("$base64"); # output -> U2FsdGVkX18m1jVqRTxANhcEj6aADeOn+2cccDft2eYAMfOkYCvAAkTIOv01VHc/ $de_base64 = decode_base64($base64); $decrypted = $cipher->decrypt($de_base64); $c = $cipher->finish; print("$decrypted

Rijndael Padding Error

你离开我真会死。 提交于 2019-12-05 16:55:21
Hello I am trying to encrypt / decrypt a string via Rijaendal. I simply can't figure out why the decryption blows up. I always end up with an incorrect padding error. One thing that throws me off is the result of my encryption which I return as HEX array. It has a length of 14 bytes. In my decryption function, the same byte array ends up having 16 bytes upon conversion from HEX. Any help would be appreciated: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace rjandal { class Program { static void Main(string[] args) { string DataForEncrypting =

.Net and PHP Rijndael encryption not matching

梦想与她 提交于 2019-12-05 11:47:57
At first i thought it was the padding since mcrypt uses zero padding but i changed the php to use PKCS7 and get the same exact results Can anyone help? I think it has something to do with the padding in the php Test output from .Net: Key: d88f92e4fa27f6d45b49446c7fc76976 Text: Testing123 Encrypted: /DMkj7BL9Eu2LMxKhdGT+A== Encrypted after base64 decode: ?3$??K?K?,?J??? Decrypted: Testing123 Test output from PHP: Key: d88f92e4fa27f6d45b49446c7fc76976 Text: Testing123 Encrypted: K+ke5FNI5T6F6B/XvDF494+S8538Ze83cFz6v1FE89U= Encrypted after base64 decode: +éäSHå>…è×¼1x÷’óüeï7p\ú¿QDóÕ Decrypted:

Rijndael AES-128 encryption decryption in Ruby

岁酱吖の 提交于 2019-12-05 08:04:41
问题 I want to use rijndael aes128 for encryption in ruby. I have this code: cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc") cipher.encrypt cipher.key = 'abcdef0123456789abcdef0123456789' cipher.iv = '0000000000000000' encrypted = cipher.update('2~1~000024~0910~20130723092446~T~00002000~USD~F~375019001012120~0~0~00000000000~') encrypted << cipher.final which is not working. But using this PHP function: <?php function hex2bin($hex_string) { return pack('H*', $hex_string); } $data_to_encrypt =

Encrypt and decrypt doesn't give the same plain text using AES/ECB/NoPadding

假如想象 提交于 2019-12-05 06:35:30
问题 String plain1= "Test"; byte[] cipher = SplashSecure.getInstance().encrypt2(plain1); String plain2 = SplashSecure.getInstance().decrypt2(cipher); plain = Test������������������������ After decryption plainText2 should be equal to plaintext . But it's not. Encrypt/Decrypt methods. public void initKey(String key) { String paddedKey = Utils.padString(key); mKeyspec = new SecretKeySpec(Utils.getBytes(paddedKey), "AES/ECB/NoPadding"); // Utils.getBytes returns "paddedKey.getBytes("CP1252")" }

AES Rijndael on PHP server and iOS generates sometimes different ciphers

主宰稳场 提交于 2019-12-05 05:08:50
问题 I'm using NSData+AESCrypt category by Jim Dovey and NSString+AESCrypt by Michael Sedlaczek (2011-02-22). And on PHP I have a simple script: <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $key = '01234567890123456789012345678901'; $plaintext = "myworda"; $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext, MCRYPT_MODE_ECB); $base64encoded_ciphertext = base64_encode($ciphertext); echo "ciphertext: ".

C# AES Rijndael - detecting invalid passwords

余生颓废 提交于 2019-12-05 02:29:04
I'm using Rijndael to encrypt some sensitive data in my program. When the user enters an incorrect password, most of the time a CryptographicException is thrown with the message "Padding is invalid and cannot be removed.". However, with very small probability, the CryptStream does not throw an exception with the wrong password, but instead gives back an incorrectly decrypted stream. In other words, it decrypts to garbage. Any idea how to detect/prevent this? The simplest way I can think of would be to put a "magic number" at the start of the message when encrypting, and check if it's still