GSM Shop GSM Shop
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > GSM Programming & Reverse Engineering

GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets.

Reply
 
LinkBack Thread Tools Display Modes
Old 04-15-2015, 16:52   #1 (permalink)
No Life Poster
 
DYNET's Avatar
 
Join Date: Jul 2006
Location: CHINA
Age: 34
Posts: 2,736
Member: 320363
Status: Offline
Sonork: 100.1578853
Thanks Meter: 3,938
Any one can see in dec2hex codes ??


By this code i m getting perfect result till 16 th digite after 20th digit it not convert to hex any idea

Code:
Public Function dec2hex(ByVal dec As String) As String
        Dim str As String = Nothing
        Dim num2 As Double
        Dim i As Double = Double.Parse(dec)
        Do While (i > 0)
            Dim str2 As String
            num2 = (i Mod 16)
            If (num2 = 10) Then
                str2 = "a"
            ElseIf (num2 = 11) Then
                str2 = "b"
            ElseIf (num2 = 12) Then
                str2 = "c"
            ElseIf (num2 = 13) Then
                str2 = "d"
            ElseIf (num2 = 14) Then
                str2 = "e"
            ElseIf (num2 = 15) Then
                str2 = "f"
            Else
                str2 = num2.ToString
            End If
            str = (str2 & str)
            i = ((i - num2) / 16)
        Loop
        Return str.ToUpper
    End Function
I M LOOKING FOR LIKE THIS

DEC :12345678901234567890
HEX : AB54A98CEB1F0AD2

Thanks in Advance
  Reply With Quote
Old 04-15-2015, 17:24   #2 (permalink)
Freak Poster
 
Join Date: Sep 2009
Location: Indonesia
Posts: 269
Member: 1112585
Status: Offline
Sonork: 100.1645028
Thanks Meter: 91
you want make/exercise functions that convert decimals to hex,
or you want to convert dec to hex?

maybe this suit your needs
  Reply With Quote
Old 04-17-2015, 06:35   #3 (permalink)
No Life Poster
 
Join Date: Jun 2004
Location: USA
Age: 39
Posts: 1,142
Member: 67927
Status: Offline
Thanks Meter: 108
Wrong way. Use bitwise AND with FF.
  Reply With Quote
Old 04-17-2015, 07:01   #4 (permalink)
Moderator
 
Join Date: May 1999
Location: Blagoevgrad, Bulgaria
Age: 52
Posts: 1,056
Member: 73
Status: Offline
Thanks Meter: 537
Donate money to this user
From Embarcadero SYSUTILS.PAS

Code fragment:

Code:
const
  TwoHexLookup : packed array[0..255] of array[1..2] of Char =
  ('00','01','02','03','04','05','06','07','08','09','0A','0B','0C','0D','0E','0F',
   '10','11','12','13','14','15','16','17','18','19','1A','1B','1C','1D','1E','1F',
   '20','21','22','23','24','25','26','27','28','29','2A','2B','2C','2D','2E','2F',
   '30','31','32','33','34','35','36','37','38','39','3A','3B','3C','3D','3E','3F',
   '40','41','42','43','44','45','46','47','48','49','4A','4B','4C','4D','4E','4F',
   '50','51','52','53','54','55','56','57','58','59','5A','5B','5C','5D','5E','5F',
   '60','61','62','63','64','65','66','67','68','69','6A','6B','6C','6D','6E','6F',
   '70','71','72','73','74','75','76','77','78','79','7A','7B','7C','7D','7E','7F',
   '80','81','82','83','84','85','86','87','88','89','8A','8B','8C','8D','8E','8F',
   '90','91','92','93','94','95','96','97','98','99','9A','9B','9C','9D','9E','9F',
   'A0','A1','A2','A3','A4','A5','A6','A7','A8','A9','AA','AB','AC','AD','AE','AF',
   'B0','B1','B2','B3','B4','B5','B6','B7','B8','B9','BA','BB','BC','BD','BE','BF',
   'C0','C1','C2','C3','C4','C5','C6','C7','C8','C9','CA','CB','CC','CD','CE','CF',
   'D0','D1','D2','D3','D4','D5','D6','D7','D8','D9','DA','DB','DC','DD','DE','DF',
   'E0','E1','E2','E3','E4','E5','E6','E7','E8','E9','EA','EB','EC','ED','EE','EF',
   'F0','F1','F2','F3','F4','F5','F6','F7','F8','F9','FA','FB','FC','FD','FE','FF');


function _IntToHex(Value: UInt64; Digits: Integer): string;
var
  I32    : Integer;
  I, J   : UInt64;
  P      : Integer;
  NewLen : Integer;
  Sb     : TCharArray;
begin
  NewLen := 1;
  I := Value shr 4;
  while I > 0 do
  begin
    Inc(NewLen);
    I := I shr 4;
  end;
  if Digits > NewLen then
  begin
    SetLength(Sb, Digits);
    for I32 := 0 to (Digits - NewLen) - 1 do
      Sb[I32] := '0';
    P := Digits - NewLen;
  end
  else
  begin
    SetLength(Sb, NewLen);
    P := 0;
  end;
  I := Value;
  while NewLen > 2 do
  begin
    J := I and $FF;
    I := I shr 8;
    Dec(NewLen, 2);
    Sb[P + NewLen] := TwoHexLookup[J][1];
    Sb[P + NewLen + 1] := TwoHexLookup[J][2];

  end;
  if NewLen = 2 then
  begin
    Sb[P] := TwoHexLookup[I][1];
    Sb[P+1] := TwoHexLookup[I][2];
  end
  else
    Sb[P] := TwoHexLookup[I][2];

  Result := String.Create(Sb);
end;
Using:

Code:
procedure TForm1.FormCreate(Sender: TObject);
var i: int64;
    s: string;
begin
    i:=12345678901234567890;
    s:=_inttohex(i,30);
end;
Result:

Code:
s:='00000000000000AB54A98CEB1F0AD2'
__________________
You'll die as you lived in a flash of the blade,
in a corner forgotten by no one
You lived for the touch for the feel of the steel
One man, and his honor.
  Reply With Quote
The Following 2 Users Say Thank You to Victor For This Useful Post:
Old 04-19-2015, 09:20   #5 (permalink)
No Life Poster
 
DYNET's Avatar
 
Join Date: Jul 2006
Location: CHINA
Age: 34
Posts: 2,736
Member: 320363
Status: Offline
Sonork: 100.1578853
Thanks Meter: 3,938
@Victor

Thanks sir for your replay can u give me in vb.net

Regards
DYNET
  Reply With Quote
Old 04-19-2015, 10:29   #6 (permalink)
Moderator
 
Join Date: May 1999
Location: Blagoevgrad, Bulgaria
Age: 52
Posts: 1,056
Member: 73
Status: Offline
Thanks Meter: 537
Donate money to this user
Quote:
Originally Posted by DYNET View Post
@Victor

Thanks sir for your replay can u give me in vb.net

Regards
DYNET
sorry I haven't. Rewrite it. Not hard.
__________________
You'll die as you lived in a flash of the blade,
in a corner forgotten by no one
You lived for the touch for the feel of the steel
One man, and his honor.
  Reply With Quote
The Following User Says Thank You to Victor For This Useful Post:
Old 04-19-2015, 21:07   #7 (permalink)
No Life Poster
 
DYNET's Avatar
 
Join Date: Jul 2006
Location: CHINA
Age: 34
Posts: 2,736
Member: 320363
Status: Offline
Sonork: 100.1578853
Thanks Meter: 3,938
Quote:
Originally Posted by Victor View Post
sorry I haven't. Rewrite it. Not hard.
No problem I will make it IN VB

Regards
DYNET
  Reply With Quote
Old 04-23-2015, 17:33   #8 (permalink)
Insane Poster
 
Join Date: Mar 2015
Location: USA/AUS
Posts: 66
Member: 2356197
Status: Offline
Thanks Meter: 13
Do you want in same platform or different ?
  Reply With Quote
Old 04-23-2015, 19:09   #9 (permalink)
No Life Poster
 
DYNET's Avatar
 
Join Date: Jul 2006
Location: CHINA
Age: 34
Posts: 2,736
Member: 320363
Status: Offline
Sonork: 100.1578853
Thanks Meter: 3,938
Yes need on same platform
AS given in my example codes
  Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 



All times are GMT +1. The time now is 01:00.



Powered by Searchlight © 2024 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -
Page generated in 0.14830 seconds with 8 queries

SEO by vBSEO