TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Genscripter P
NA
17
688
Trying to decrypt TripleDES file using C#
Jul 9 2019 4:25 PM
I've been trying to figure this out. Backstory: Someone gave me an encrypted file. He told me the Key, the MD5 Hash, the padding, and the mode. He encrypted it in Java using a "DESede" SecretKeySpec instance. I'm trying to decrypt the file in C#.
The FBArr is the 24-byte key. P1 = file.readallbytes(path)
string
plaintext =
""
;
using
(TripleDESCryptoServiceProvider tdes =
new
TripleDESCryptoServiceProvider())
{
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
MD5CryptoServiceProvider MD5b =
new
MD5CryptoServiceProvider();
ICryptoTransform decryptor = tdes.CreateDecryptor(FBArr, FBArr);
using
(MemoryStream ms =
new
MemoryStream(p1))
{
using
(CryptoStream cs =
new
CryptoStream(ms, decryptor, CryptoStreamMode.Read))
{
using
(StreamReader reader =
new
StreamReader(cs))
plaintext = reader.ReadToEnd();
}
}
}
As you can see from the code, the MD5b variable doesn't do anything. Also, the IV is just set exactly to the Key. Even with these irrelevancies, I'm able to decrypt half my file. I need to decrypt the rest of the file. The decryption looks a lot like this:
PK \2\5\1\5\1\8\2\4\2\0\?n?\Rotate??????????????%??8p??(u??Z??%??8p??(u??Z??%??8p??(u??Z\0\0\0\0\0\0\0\0\0\0\0\RotatePKRotate
As you can see, some of the text at the beginning and end of the file is good, and some words are showing up. But the middle is crazy. Why can't I decrypt all the file?
I think the fact that I'm not using my MD5 Hash is the reason why my key isn't fully decrypting the whole file. I completely understand that MD5 and TripleDES is not secure anymore and I shouldn't use this method in the future. I didn't make that call. I just need to resolve this using the encryption that was given to me.
Reply
Answers (
2
)
Help me in KIBANA(Elastic Search)
Rate yourself out of 10