tarequl.hassan Posted April 13, 2021 Posted April 13, 2021 (edited) Hi Can anyone convert this delphi code to BV6? procedure TKeyGen.Button1Click(Sender: TObject); const Const_Array : array[0..7] of Char = ('e','n','c','r','y','w','e','b'); Var StrName, Part2, Code : string; i, AL, Last_Char : Integer; begin Code := '' ; StrName := Edit1.Text; If StrName = '' then Edit2.Text := 'Enter your Name !!!' else Begin For i := 0 to length(StrName) - 1 do begin AL := ((Ord(StrName[i + 1]) + (i) + Length(StrName) + Ord(Const_Array[(I and 80000007)])) mod 10) + 48; Code := Char (AL) + Code ; end; Last_Char := ((Length(StrName) + 112) mod 10) + 48; Edit2.Text := Code + Char(Last_Char); end; end; THANKS Delphi registration code.txt Edited April 13, 2021 by tarequl.hassan
tonyweb Posted April 30, 2021 Posted April 30, 2021 (edited) @tarequl.hassan I understand this is not what you want to hear but IMHO you should try converting it on your own, instead of asking others to do so for you. It will be more rewarding. I mean: the code is not that difficult to understand and with a couple of online searches you would find the way to convert it, if you already know VB6. Personally I think you would just need the following links to understand that code. http://www.delphibasics.co.uk/Article.asp?Name=Arrays http://www.delphibasics.co.uk/RTL.asp?Name=ord http://www.delphibasics.co.uk/rtl.asp?name=char Good luck! Regards, Tony Edited April 30, 2021 by tonyweb 1
ToMKoL Posted April 30, 2021 Posted April 30, 2021 Try this. I'm not sure if this is correct (haven't tried). Procedure keygen_click() Dim enc = "encryweb" If (Len(Text1.Text) = 0) Then Text2.Text = "Enter some name!" Exit Sub End If For i = 1 to Len(Text1.Text): code = code & Chr(Asc(Mid(Text1.Text, i + 1, 1)) + i + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48) Next i code = code & Chr(((Len(Text1.Text) + 112) mod 10) + 48) Text2.Text = code Also I'm not sure why there is 'mod 10' in this line: Ord(Const_Array[(I and 80000007)])) mod 10) String is 8 chars so 'and ' will work like 'mod' in this case and give us current 'string[i]'. 1
T-rad Posted May 2, 2021 Posted May 2, 2021 VB6 is not 0 based ( per the' i' starting with 1, not 0 in the for loop), therefore this will not work code = code & Chr(Asc(Mid(Text1.Text, i + 1, 1)) + i + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48) it will have to be something more like this like this providing the rest works code = code & Chr(Asc(Mid(Text1.Text, i, 1)) + (i - 1) + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48) also the Delphi code reads Code := Char (AL) + Code ; so shouldn't the vb6 code read code = Chr(Asc(Mid(Text1.Text, i, 1)) + (i - 1) + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48) & code just my thoughts... T-rad 1
nabila Posted May 17, 2021 Posted May 17, 2021 On 4/30/2021 at 8:25 PM, ToMKoL said: Try this. I'm not sure if this is correct (haven't tried). Procedure keygen_click() Dim enc = "encryweb" If (Len(Text1.Text) = 0) Then Text2.Text = "Enter some name!" Exit Sub End If For i = 1 to Len(Text1.Text): code = code & Chr(Asc(Mid(Text1.Text, i + 1, 1)) + i + Len(Text1.Text) + Asc(Mid(enc, (i mod 7), 1)) + 48) Next i code = code & Chr(((Len(Text1.Text) + 112) mod 10) + 48) Text2.Text = code Also I'm not sure why there is 'mod 10' in this line: Ord(Const_Array[(I and 80000007)])) mod 10) String is 8 chars so 'and ' will work like 'mod' in this case and give us current 'string[i]'. This code is not working for me. Anyone tested?
ToMKoL Posted May 22, 2021 Posted May 22, 2021 Try this one. Tested and it should work as delphi version. delphivb.zip 1
tarequl.hassan Posted May 23, 2021 Author Posted May 23, 2021 20 hours ago, ToMKoL said: Try this one. Tested and it should work as delphi version. delphivb.zip 5.06 kB · 3 downloads Thanks. But it doesn't generate the actual results. I am sending the Delphi and assembly one for checking.
kao Posted May 23, 2021 Posted May 23, 2021 @ToMKoL: I'm able to spot one mistake in your code: Asc(Mid(enc, (i Mod 7), i)) should most likely read Asc(Mid(enc, (i Mod 8), 1)) Maybe there are more issues, but I'm not really a VB wizard... 1
ToMKoL Posted May 23, 2021 Posted May 23, 2021 @tarequl.hassan: I've replied to You in PM. Any compiled version will be fine to check. @kao: Thanks for spotting error. I'm also no VB coder (this is my second program in basic). Also my Delphi coding ended over 20+ years ago with D4 so I might forgot few things and maybe read source code wrong. Will correct mistake pointed out and upload corrected version.
tarequl.hassan Posted May 23, 2021 Author Posted May 23, 2021 1 hour ago, ToMKoL said: @tarequl.hassan: I've replied to You in PM. Any compiled version will be fine to check. @kao: Thanks for spotting error. I'm also no VB coder (this is my second program in basic). Also my Delphi coding ended over 20+ years ago with D4 so I might forgot few things and maybe read source code wrong. Will correct mistake pointed out and upload corrected version. Please find the proggie in delphi and masm. Woul you please check? In ASM.rar Project1.rar
kao Posted May 23, 2021 Posted May 23, 2021 There were few more small mistakes, including one in my earlier fix. This one is tested and output matches your ASM/Delphi versions. Option Explicit Procedure keygen_click() Dim enc As String Dim username As String Dim serial As String Dim idx1 As Integer Dim i As Integer enc = "encryweb" username = Text1.Text If (Len(username) = 0) Then Text2.Text = "Enter some name!" Exit Sub End If serial = "" For i = 0 To Len(username) - 1 ' calculate magic number idx1 = Asc(Mid(username, i + 1, 1)) + _ i + _ Len(username) + _ Asc(Mid(enc, (i Mod 8) + 1, 1)) ' prepend the symbol to generated serial serial = Chr(idx1 Mod 10 + 48) & serial Next i ' finally, append one more symbol that depends on username length serial = serial & Chr(((Len(username) + 112) Mod 10) + 48) Text2.Text = serial End Sub 1
ToMKoL Posted May 24, 2021 Posted May 24, 2021 @tarequl.hassanPlease check snippet provided by kao. Hope that this time it will work for You. 1
tarequl.hassan Posted May 24, 2021 Author Posted May 24, 2021 2 minutes ago, ToMKoL said: @tarequl.hassanPlease check snippet provided by kao. Hope that this time it will work for You. I sent a mail to you with link. Have you checked? Thanks
tarequl.hassan Posted May 24, 2021 Author Posted May 24, 2021 18 hours ago, kao said: There were few more small mistakes, including one in my earlier fix. This one is tested and output matches your ASM/Delphi versions. Option Explicit Procedure keygen_click() Dim enc As String Dim username As String Dim serial As String Dim idx1 As Integer Dim i As Integer enc = "encryweb" username = Text1.Text If (Len(username) = 0) Then Text2.Text = "Enter some name!" Exit Sub End If serial = "" For i = 0 To Len(username) - 1 ' calculate magic number idx1 = Asc(Mid(username, i + 1, 1)) + _ i + _ Len(username) + _ Asc(Mid(enc, (i Mod 8) + 1, 1)) ' prepend the symbol to generated serial serial = Chr(idx1 Mod 10 + 48) & serial Next i ' finally, append one more symbol that depends on username length serial = serial & Chr(((Len(username) + 112) Mod 10) + 48) Text2.Text = serial End Sub Great!!! It works perfectly. Thanks kao.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now