Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 17, 2020 9:35 PM
I have an issue in decryption. The issue is when used another textbox (any textbox not one used for encryption) iI press decrypt button error message "The input is not a valid Base-64 string"(I attached screen shot of error message), but there is no error when used a textox that used for encrption, value from the to decrypt decrypt I wonder how to solve this issue
In summery, I used AES as an encryption algorithm and let say there is a windows form have three text box one is the input message (in my program is "txt_to_be_sent.Text") and one for output cipher text after encryption (in my program is "txt_sender1_encryption.Text"),and one for decryption (in my program is "txt_incoming_encrypted.Text" so when transfer text from copy cipher text to "txt_incoming_encrypted" and press decryption button the error message appeared, but when use "txt_sender1_encryption.Text" to decrypt cyfertext the process done without any error.
The error is appers that there are 0/0/.......... and it as in this Image Error Valu
All replies (8)
Thursday, August 20, 2020 9:51 AM ✅Answered | 1 vote
OK, but how. I had used several methods but i field
Show your experiments, the code that builds such string.
As a workaround, you can try fixing the bad string before decoding. Something like this:
string bad_string = "\u0018\0G1DSP7X+Mmtw2zrpnCh+QQ==\0\0\0\0\0\0\0\0\0\0\0\0\0"; // (from your picture, or ‘Encrypted_message_from_sender1.Text’)
string fixed_string = string.Concat( bad_string.Skip( 2 ).TakeWhile( c => c != '\0' ));
byte[] bytes = Convert.FromBase64String( fixed_string );
Tuesday, August 18, 2020 3:10 AM
Hi mkf-iq,
Thank you for posting here.
What is the code used to generate txt_incoming_encrypted.Text, could you please provide the relevant code for our reference? This will help us find problems quickly.
Best Regards,
Timon
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Tuesday, August 18, 2020 4:46 AM
It seems that you should skip the first four bytes, which contain the length of Base64 string, then take the corresponding amount of characters — “G1D…Q==”. This part represents the string to be decoded.
Tuesday, August 18, 2020 3:05 PM
Hello Timon and thx for reply, for more explanation i used stego to hide ciphertext, and I used get, set to transfer text between to windows (WPF) so txt incoming encrypted.Text is the ciphertext after decode stego message
Thursday, August 20, 2020 9:29 AM
OK, but how. I had used several methods but I failed
Thursday, August 20, 2020 2:28 PM
Great solution, It fixed now. Thank you alot
Thursday, August 20, 2020 3:09 PM
However, need to asking you, For stego thing I used your solution and it perfect but it not works when the text of secret message is above 39 charcters
My new code based on your solution is:
Encrypted_message_from_sender2.Text = Encoding.UTF8.GetString(ArabicSteg.Decode(txt_incoming_encoded2.Text, StegScheme.MSCUKAT));
Encrypted_message_from_sender2.Text = string.Concat(Encrypted_message_from_sender2.Text.Skip(2).TakeWhile(c => c != '\0'));
Thursday, August 20, 2020 3:14 PM
However, need to asking you, For stego thing I used your solution and it perfect but it not works when the text of secret message is above 39 charcters
My new code based on your solution is:
Encrypted_message_from_sender2.Text = Encoding.UTF8.GetString(ArabicSteg.Decode(txt_incoming_encoded2.Text, StegScheme.MSCUKAT)); Encrypted_message_from_sender2.Text = string.Concat(Encrypted_message_from_sender2.Text.Skip(2).TakeWhile(c => c != '\0'));
Show the value of txt_incoming_encoded2.Text before you execute the first line, and the value of Encrypted_message_from_sender2.Text before you execute the second line.