Ask a Question related to ASP.NET Security, Design and Development.
-
Yuna84 #1
I've problem with Rijndael PKCS7
I've tried with a simple program in vb.net but when i'm going to
decript in my messagebox appears this message: PKCS7 padding is
invalid and cannot be removed.
I've found this few lines of codes in this site:
[url]http://www.dotnethell.it/articles/article.aspx?ArticleID=93[/url]
I've trasform in vb.net and this is the result
Imports system.security.cryptography
imports system.text
('I don't write the other normal imports)
Public Function Encode(ByVal s As String, ByVal chiave As String,
ByVal IV As String) As String
Dim ascii As New ASCIIEncoding
Dim rjm As New RijndaelManaged
rjm.KeySize = 128
rjm.BlockSize = 128
rjm.Key = ascii.GetBytes(chiave)
rjm.Key = ascii.GetBytes(IV)
Dim input() As Byte = Encoding.UTF7.GetBytes(s)
Dim output() As Byte =
rjm.CreateEncryptor().TransformFinalBlock(input, 0, input.Length)
Return Convert.ToBase64String(output)
End Function
Public Function Decode(ByVal s As String, ByVal chiave As String,
ByVal IV As String) As String
Dim rjm As New RijndaelManaged
Dim ascii As New ASCIIEncoding
rjm.KeySize = 128
rjm.BlockSize = 128
rjm.Key = ascii.GetBytes(chiave)
rjm.Key = ascii.GetBytes(IV)
Try
Dim input() As Byte = Convert.FromBase64String(s)
Dim output() As Byte =
rjm.CreateDecryptor().TransformFinalBlock(input, 0, input.Length)
Return Encoding.UTF7.GetString(output)
Catch e As Exception
MessageBox.Show(e.Message & " " & e.Source)
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
txtDecripta.Text = (Encode(txtCripta.Text, "AsDfGhJkLqPwOeIr",
"RiEoWpQlKjHgFdSa"))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Console.WriteLine(Decode(txtDecripta.Text, "AsDfGhJkLqPwOeIr",
"RiEoWpQlKjHgFdSa"))
End Sub
Please. This is an emergency!!!! Can you help me???
Yuna84 Guest
-
contribute problem - access denied file may not existpermission problem
Recieving the following error message - "access denied file may not exist , or there could be a permission problem" this happened this morning ,... -
Problem playing Quicktime thru .DCR embedded in HTML - pathreferencing problem?
Greetings earthlings and Director heads. Here's the problem: created an HTML file containing shockwave (dcr) movie that calls quicktime movies in... -
Uploading problem = weird warning (was: access denied problem.....)
Hi, I had a problem where my upload form was not working on our production server but was working on two other servers, after checking the... -
#21611 [Opn]: Problem with version_compare() (Was: Problem with pear cli and release numbers)
ID: 21611 Updated by: et@php.net -Summary: Problem with pear cli and release numbers Reported By: jan at horde... -
Problem with Apache Web Server config file and PHP (please give advice on what problem may be me)
HI: Can anyone refer me to someone that can help with the problem below. I installed Apache Web Server on my laptop which has Windows XP. I... -
Hernan de Lahitte #2
Re: I've problem with Rijndael PKCS7
I suggest you to take a look at the sample in
[url]http://sourceforge.net/projects/ncrypto/[/url]
You will find a good sample in CryptoHelper.Encrypt or Decrypt methods.
In your sample, I notice the different encoding methods when encrypting and
decrypting and the algorithm usage is not very "clean" (Close() the alg
instance when finishing) nor readable.
Hernan de Lahitte
Lagash Systems S.A.
[url]http://weblogs.asp.net/hernandl[/url]
This posting is provided "AS IS" with no warranties, and confers no rights.
"Yuna84" <acquargento@yahoo.it> wrote in message
news:48144a5.0404160511.38097908@posting.google.co m...> I've tried with a simple program in vb.net but when i'm going to
> decript in my messagebox appears this message: PKCS7 padding is
> invalid and cannot be removed.
>
> I've found this few lines of codes in this site:
> [url]http://www.dotnethell.it/articles/article.aspx?ArticleID=93[/url]
>
> I've trasform in vb.net and this is the result
>
> Imports system.security.cryptography
> imports system.text
> ('I don't write the other normal imports)
>
>
>
> Public Function Encode(ByVal s As String, ByVal chiave As String,
> ByVal IV As String) As String
> Dim ascii As New ASCIIEncoding
> Dim rjm As New RijndaelManaged
> rjm.KeySize = 128
> rjm.BlockSize = 128
> rjm.Key = ascii.GetBytes(chiave)
> rjm.Key = ascii.GetBytes(IV)
> Dim input() As Byte = Encoding.UTF7.GetBytes(s)
> Dim output() As Byte =
> rjm.CreateEncryptor().TransformFinalBlock(input, 0, input.Length)
>
> Return Convert.ToBase64String(output)
> End Function
>
> Public Function Decode(ByVal s As String, ByVal chiave As String,
> ByVal IV As String) As String
> Dim rjm As New RijndaelManaged
> Dim ascii As New ASCIIEncoding
>
> rjm.KeySize = 128
> rjm.BlockSize = 128
> rjm.Key = ascii.GetBytes(chiave)
> rjm.Key = ascii.GetBytes(IV)
> Try
> Dim input() As Byte = Convert.FromBase64String(s)
> Dim output() As Byte =
> rjm.CreateDecryptor().TransformFinalBlock(input, 0, input.Length)
> Return Encoding.UTF7.GetString(output)
> Catch e As Exception
> MessageBox.Show(e.Message & " " & e.Source)
> End Try
> End Function
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles Button1.Click
> txtDecripta.Text = (Encode(txtCripta.Text, "AsDfGhJkLqPwOeIr",
> "RiEoWpQlKjHgFdSa"))
> End Sub
>
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles Button2.Click
> Console.WriteLine(Decode(txtDecripta.Text, "AsDfGhJkLqPwOeIr",
> "RiEoWpQlKjHgFdSa"))
> End Sub
>
> Please. This is an emergency!!!! Can you help me???
Hernan de Lahitte Guest
-
DotNetJunkies User #3
Re: I've problem with Rijndael PKCS7
Sometimes the problem is with an altered encrypted string. I found this out when I was trying to decrypt a string I had inadvertently changed to lower case.
---
Posted using Wimdows.net NntpNews Component -
Post Made from [url]http://www.DotNetJunkies.com/newsgroups[/url] Our newsgroup engine supports Post Alerts, Ratings, and Searching.
DotNetJunkies User Guest



Reply With Quote

