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
Austin Muts
1.4k
333
126.4k
AES 128 -bit Encryption-Decryption in C#
Apr 6 2019 1:46 PM
I am trying to decrypt the given text with the key but i am getting error "The input data is not a complete block" Check code below and help if you can .
private
string
DecryptOTP(
string
decryptethis)
{
decryptethis =
"4931cb6f11c9f8b24f0b05f9ec9a2cc0"
;
string
decryptionKey =
string
.Empty;
decryptionKey =
"f22704b8bc0dcc606303b5eb97332630"
;
byte
[] cipherBytes = Convert.FromBase64String(decryptedOTP.Trim());
using
(Aes encryptor = Aes.Create())
{
Rfc2898DeriveBytes pdb =
new
Rfc2898DeriveBytes(decryptionKey.Trim(),
new
byte
[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
encryptor.Key = pdb.GetBytes(32);
encryptor.IV = pdb.GetBytes(16);
using
(MemoryStream ms =
new
MemoryStream())
{
using
(CryptoStream cs =
new
CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
{
cs.Write(cipherBytes, 0, cipherBytes.Length);
cs.Close();
}
decryptethis = Encoding.Unicode.GetString(ms.ToArray());
}
}
return
decryptethis;
}
Reply
Answers (
6
)
How to search from sqlite into listview into xamarin form
confusion about code