473,837 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to decrypt data with mcrypt ..

13 New Member
I am encrypting the data with blowfish CBC mode in C using openssl.
I am trying to decrypt the data with the key using PHP mycrypt.But it does not give me the actual data but some garbage text.I am able to decrypt and encrypt with mcrypt but if i encrypt with c i am unable to decrypt with PHP.
Mar 2 '10 #1
16 7145
Atli
5,058 Recognized Expert Expert
Hey.

Not much we can do for you without seeing your code, I'm afraid.
Mar 2 '10 #2
akaash19
13 New Member
Oh certainly..
I am using command line ssl to encrypt file using blowfish CBC mode.

The decryption code is using mcrypt.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //base 64 decoding the encrypted data.
  3. $data = base64_decode('BdRY7DN8iPDdjdsevowiZQ==');
  4. $key ='12345678';
  5. $iv ='1234';
  6.  
  7. $res2 = mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$data,MCRYPT_MODE_CBC,$iv);
  8. echo $res2;
  9. ?>
  10.  
Regards
akaash
Mar 2 '10 #3
akaash19
13 New Member
Any ideas?
regards
akaash
Mar 3 '10 #4
Atli
5,058 Recognized Expert Expert
I can't see anything wrong with that, unless:
  1. Your $key or $iv are incorrect.
  2. You input data is invalid
  3. Your C code is doing something wrong. - Which, honestly, is a lot more likely than your PHP code being wrong.
  4. ... Nope, that's all I've got.
One thing, though. Why do you decrypt the data as Base64 before sending it to Mcrypt?
Mar 3 '10 #5
akaash19
13 New Member
hi,,thanks for the input.
I am doing base64 decode because data that i get as encrypted is garbage type.doing base64 helps to make it easy to send.

Regards
sumit
Mar 4 '10 #6
akaash19
13 New Member
Hello friends.I have been trying to encrypt data in C and decrypt in PHP.SO far no success.:(
I want to know if any of you have done encryption in C and PHP.
If yes,please let me know and how.
I encrypt data in c and when in decrypt in php,i get vague characters.
Regards
akaash
Mar 9 '10 #7
RedSon
5,000 Recognized Expert Expert
Are you sure you are using the same encryption algorithim. If you encrypt something in C and write the encrypted text to a plain old text file, then you should be able to take that to any platform and decrypt it.

If you encrypted file that you encrypted in C will not decrypt using PHP then I would blame the user not the technology.
Mar 9 '10 #8
akaash19
13 New Member
I do agree that but cross platform encryption has much more that just key and iv like padding,file format etc .
I want to know where i am missing those details and are there more to be counted.I guess person who has done this in php and C is the best judge.

regards all
akaash
Mar 9 '10 #9
RedSon
5,000 Recognized Expert Expert
does it say that mcrypt_decrypt needs a $data value that has been base64_decoded?

That would be my first suspicion.
Mar 9 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7313
by: Oliver Spiesshofer | last post by:
Hi, I am trying to load the LDAP and the MCrypt module under WinXP and PHP Version 4.3.7. The strange thing is that I have several other modules that work just fine: extension=php_bz2.dll extension=php_gd2.dll extension=php_mbstring.dll
7
17882
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm able to encrypt and then decrypt data okay as in the following code: // encrypt the data // Encryptor enc = new Encryptor(EncryptionAlgorithm.TripleDes); byte key = Encoding.ASCII.GetBytes("0123456789012345");
1
4428
by: Y Store Tools | last post by:
I've just started playing with mcrypt for encryption but not sure if I'll need to write my own. Basically I don't need anything advanced for protection but want to mask the data so it's not easily deciphered....BUT, I need the encrypted data to be something that can be used as an email address (the user portion of the address, not domain). So it needs to only output standard ascii characters I can use there. Is there an easy way to...
0
2508
by: Chris Fink | last post by:
I have walked through all of the WSE 3 Hands on Labs and got everything working fine. When I create my own certificate and install it in the stores, my client application that is consuming my WSE enabled webservice receives the following error (noted at the very bottom of this post). My objective here is to create and secure a service application (webservice) using an x509 test cert that requests a client certificate; and to create a...
0
1174
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4. Using code from this newsgroup, I have a decrypt function, trying to decrypt data (encryped using a corresponding mcrypt function). What am I doing wrong? These are the warnings, generated from the decrypt function (lines are marked in the function, code follows) Warning: pack() : Type H: not enough characters in string in /usr/local/apache2/htdocs/refillingstation/form_fns.php on
8
6300
by: =?Utf-8?B?RGFuTQ==?= | last post by:
Can someone help with the following problem. I am sending an encrypted SOAP message to a .NET 2.0 + WSE 3.0 web service. When .NET attempts to decrypt the message it cannot read the private key of the X509 token it requires (or so it says). I have followed the instructions in the error message and given the userid full access to the certificate. I have also tried running .NET under my administrators userid which was used to create the...
3
8774
by: =?UTF-8?Q?Ahmad_=E3=8B=A1_Baitalmal?= | last post by:
Hi, I'm having a hard time getting python-mcrypt extension to build. I installed libmcrypt with --prefix=/usr and I checked that the library exists -rwxr-xr-x 1 root wheel 352K Sep 19 16:53 /usr/lib/libmcrypt. 4.4.8.dylib* lrwxr-xr-x 1 root wheel 21B Sep 19 16:53 /usr/lib/libmcrypt. 4.dylib@ -libmcrypt.4.4.8.dylib lrwxr-xr-x 1 root wheel 21B Sep 19 16:53 /usr/lib/
1
6436
by: Elliot | last post by:
When decrypt the xml, output "Unable to retrieve the decryption key." Can anyone help me solve the problem? I got the code from http://msdn.microsoft.com/en-us/library/ms229746.aspx using System; using System.Xml; using System.Security.Cryptography; using System.Security.Cryptography.Xml;
0
4618
by: FarooqRafiq | last post by:
Hi, My requirement is that a string is encrypted in VB.NET and sent to PHP, PHP decrypts the string (till here the logic is working) and then the PHP should encrtyp (where i am having problems) and send the data to VB.NET application. The proble is in encrypting in PHP side. PHP Code <?php //$syscode=$_REQUEST; //The actual string is "blueberry" which is encrypted in VB.NET and sent to PHP $syscode = "8yN73RDmMFuXo9ux8QKC6w==";...
5
5960
by: simon2x1 | last post by:
how can i decrypt password with i encryted with md5 i try using mcrypt it did not work <?PHP $sql = "SELECT password FROM user WHERE email='$email_to'"; $result = mysql_query($sql); $rows = mysql_fetch_array($result); $password = $rows; $$your_password = mcrypt --- this did not work echo "$your_password";
0
9827
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10560
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10609
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10263
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4468
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4034
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3120
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.