473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to decrypt byte after encoding it to a string?

My problem is in encryption and decryption using RSA, in my project I need to encrypt some string using the public key and send the results via some socket to another client to decrypt it using the relative private key.
My encryption function return byte[] and I encode it to string to be able to send it also I add some other data to this string and then in the other side I break it again and get the encrypted part off and then again turn it back to byte[] form. When I try to decrypt it an error is raised:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Exception in thread "main" javax.crypto.BadPaddingException: Data must start with zero
  3.     at sun.security.rsa.RSAPadding.unpadV15(Unknown Source)
  4.     at sun.security.rsa.RSAPadding.unpad(Unknown Source)
  5.     at com.sun.crypto.provider.RSACipher.a(DashoA13*..)
  6.     at com.sun.crypto.provider.RSACipher.engineDoFinal(DashoA13*..)
  7.     at javax.crypto.Cipher.doFinal(DashoA13*..)
  8.  
I try to decrypt the original byte[] in the server side and I succeeded but when I convert it to string and back again to byte[] and then decrypt it the same error is appeared . I believe that the problem is in converting to and from string.
Can anyone help me to solve that?
Nov 13 '10 #1
0 1351

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

Similar topics

1
by: D. Alvarado | last post by:
On my Fedora Core 2 Linux dev box, I have installed mcrypt and compiled PHP with the --with-mcrypt option. I am concerned that when I move to another hosting enviornment mcrypt will not be...
1
by: Jase H | last post by:
Hello, I have a ASP.NET web application problem involving the data encryption and decryption assembly(DLL) used on the connection string value that is set in the webconfig file. The problem...
5
by: Robert Bull | last post by:
I am looking for an example of encryption/decryption in asp.net. I want to encrypt a string before I send it to a Web Service, decrypt it on the Web Service then encrypt the results on the Web...
2
by: almurph | last post by:
Hi everyone, Can you help me please? I am having a problem with the encryption/decryption of words with the Irish fada in them. The Irish fada is like this: áéíóú/ÁÉÍÓÚ. It's kind of like the...
2
by: tfoxusenet | last post by:
Hi, I need to encrypt/decrypt some data for my C# application that can also be read on a unix system, and need a quick, simple, cross-platform solution I can embed in my own code that doesn't...
3
by: Mythran | last post by:
I have googled and tested and tried and still I can't seem to implement a simple encryption/decryption console application. My goal is to create two methods. public byte Encrypt(string...
1
by: ppuniversal | last post by:
Hello, I am making a DES encryption/decryption program using OpenSSL library. I am using function des_ecb_encrypt(des_cblock *input, des_cblock *output, des_cblock *keysched, int mode); ...
0
by: Rajeev Kumar Sarawagi | last post by:
Can anyone say that the difference between oracle and informix
0
by: Dipanwita | last post by:
I have written a RSA encryption/decryption function in c using the formula a = b^c %n. For solving the equation I have used Squaring and multiplying method for modulo exponentiation . These...
3
by: =?Utf-8?B?TG9yZW4=?= | last post by:
I’m trying to encrypt and decrypt a file in vb.net. I am using the TripleDESCryptoServiceProvider encryption found in System.Security.Cryptography. Below is the code for my Encrypt and Decrypt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.