16,017,069 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by muchabiseki (Top 6 by date)
muchabiseki
30-Sep-11 8:57am
View
thanks again, that is what i did but it still give me problem.
here it is
Public Function decrypt1(ByVal str, ByVal pwd) As String
Try
If (str Is Nothing Or str.length < 8) Then
Return Nothing
End If
If (pwd Is Nothing Or pwd.length <= 0) Then
Return Nothing
End If
Dim prand As String = ""
For i As Integer = 0 To pwd.length - 1
'prand += pwd.chars(i).ToString()
prand += Asc(pwd.chars(i).ToString).ToString
Next
'Dim sPos As VariantType = Math.Floor(prand.length / 5)
'Dim mult As VariantType = ParseInt(prand.Chars(sPos) + prand.Chars(sPos * 2) + prand.Chars(sPos * 3) + prand.Chars(sPos * 4) + prand.Chars(sPos * 5))
'Dim incr As VariantType = Math.Round(pwd.length / 2)
'Dim modu As VariantType = Math.Pow(2, 31) - 1
'Dim salt As VariantType = ParseInt(str.substring(str.length - 8, str.length), 16)
Dim sPos As Integer = Math.Floor(prand.Length / 5)
Dim mult1 As String = ""
Try
mult1 = CInt(prand.Chars(sPos).ToString).ToString & CInt(prand.Chars(sPos * 2).ToString).ToString & _
CInt(prand.Chars(sPos * 3).ToString).ToString & CInt(prand.Chars(sPos * 4).ToString).ToString & CInt(prand.Chars(sPos * 5).ToString)
Catch ex As Exception
mult1 = CInt(prand.Chars(sPos).ToString).ToString & CInt(prand.Chars(sPos * 2).ToString).ToString & _
CInt(prand.Chars(sPos * 3).ToString).ToString & CInt(prand.Chars(sPos * 4).ToString).ToString
End Try
Dim mult As Integer = CInt(mult1)
'Dim mult As VariantType = Int32.TryParse(prand.Chars(sPos) + prand.Chars(sPos * 2) + prand.Chars(sPos * 3) + prand.Chars(sPos * 4) + prand.Chars(sPos * 5), 16)
Dim incr As Double = Math.Round(pwd.length / 2)
Dim modu As Double = Math.Pow(2, 31) - 1
' Dim salt As VariantType = Val(str.substring(str.length - 8, str.length))
'str = str.substring(0, str.length - 8)
'Dim salt As VariantType = Val(str.Substring(str.length - 8, str.length - (str.length - 8)))
Dim salt As Long '= Int32.TryParse(str.Substring(str.length - 8, str.length - (str.length - 8)), 16)
salt = ReturnBinHexToInteger(str.Substring(str.length - 8, 8))
str = str.Substring(0, str.length - 8)
prand += salt.ToString
' while (prand.length > 10) {
' prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
'}
'prand = (mult * prand + incr) % modu;
''
'prand = prand.Substring(0, 10)
Dim tempprand As String = ""
While (prand.Length > 10)
Try
If prand = tempprand Then 'endless loop handle
prand = FormatNumber(prand, 0, Microsoft.VisualBasic.TriState.False, Microsoft.VisualBasic.TriState.False, Microsoft.VisualBasic.TriState.False)
Exit While
End If
Catch ex As Exception
End Try
'prand = (CDbl(prand.Substring(0, 10)) + FormatNumber(prand.Substring(10, prand.Length - 10), -1, Microsoft.VisualBasic.TriState.False, Microsoft.VisualBasic.TriState.False, Microsoft.VisualBasic.TriState.False)).ToString
tempprand = prand
prand = FormatNumber(CDbl(prand.Substring(0, 10)) + CDbl(prand.Substring(10, prand.Length - 10)), -1, Microsoft.VisualBasic.TriState.False, Microsoft.VisualBasic.TriState.False, Microsoft.VisualBasic.TriState.False)
'prand = (prand.Substring(0, 10)) + (prand.Substring(10, prand.Length - 10))
End While
prand = (mult * p
muchabiseki
30-Sep-11 5:32am
View
thanks for your reply. ive tried to convert the code to vb.net cos dats what im using.but im having dificulties in doing that especially with the java functions like (ParseInt, substring the way it is formated).parseint from vb.net is completely different from the java
please help
muchabiseki
30-Sep-11 4:42am
View
yes thats right
muchabiseki
30-Sep-11 4:16am
View
so that is why im asking if there is a way to call it from web service
muchabiseki
30-Sep-11 4:15am
View
i do have this function in javascript and is working fine, but my main problem is when i try and convert it to vb.net is not working correctly
function decrypt(str, pwd) {
alert("i decrypt")
if (str == null || str.length < 8) {
alert("A salt value could not be extracted from the encrypted message because it's length is too short. The message cannot be decrypted.");
return;
}
if (pwd == null || pwd.length <= 0) {
alert("Please enter a password with which to decrypt the message.");
return;
}
var prand = "";
for (var i = 0; i < pwd.length; i++) {
prand += pwd.charCodeAt(i).toString();
}
var sPos = Math.floor(prand.length / 5);
//alert("Prand" + prand);
var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5));
//alert(mult); //18168
//alert(pwd);
// alert(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5));
//alert(prand.charAt(sPos));
//alert(prand.charAt(sPos*2));
//alert(prand.charAt(sPos*3));
var incr = Math.round(pwd.length / 2);
var modu = Math.pow(2, 31) - 1;
var tp = str.substring(str.length - 8, str.length);
var salt = parseInt(tp, 16);
str = str.substring(0, str.length - 8);
prand += salt;
while (prand.length > 10) {
prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
}
alert(prand);
prand = (mult * prand + incr) % modu;
var enc_chr = "";
var enc_str = "";
for (var i = 0; i < str.length; i += 2) {
enc_chr = parseInt(parseInt(str.substring(i, i + 2), 16) ^ Math.floor((prand / modu) * 255));
enc_str += String.fromCharCode(enc_chr);
prand = (mult * prand + incr) % modu;
}
return enc_str;
}
muchabiseki
30-Sep-11 4:10am
View
no, before the web service complete its process i want to use a function in javascrip to decrypt the encrypted string
Show More