What's new
PinoyTechnician

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

pantech calculator source code

fred

Registered
Joined
Jun 12, 2014
Messages
356
Reaction score
4
Points
31
sa mga advance user eto...

dahil may naglabas nito sa ibang forum labas na rin natin dito :D

PHP:
 unit Pantech;

interface

uses SysUtils;

procedure Calculate_P1(IMEI: String; var StrNCK: String);

implementation

const
  LEN = 607;
  TAP = 273;
  MASK = $7FFFFFFF;
  A = 48271;
  M = 2147483647;
  Q = 44488;
  R = 3399;

var
  Table_00: Array [0..9] of Byte = (0, 6, 1, 8, 7, 5, 3, 2, 9, 4);
  Table_01: Array [0..9] of Byte = (0, 2, 6, 6, 9, 5, 1, 4, 3, 8);
  Table_10: Array [0..9] of Byte = (0, 4, 9, 2, 3, 5, 7, 8, 1, 6);
  Table_11: Array [0..9] of Byte = (0, 8, 3, 4, 1, 5, 9, 6, 7, 2);
  Table_2: Array [0..99] of Byte = ($11, $5D, $5B, $5A, $58, $57, 5, 7, 9, $12,
                                    1, $45, $51, $50, $4E, $18, $16, $13, $1F,
                                    $64, 2, $1E, $3C, $24, $23, $3F, $43, $2A,
                                    $47, $63, $C, $1D, $44, $32, $35, $38, $2B,
                                    $21, $48, $59, $F, $1C, $27, $37, $2C, $31,
                                    $36, $3E, $49, $56, $55, $1B, $28, $2D, $3A,
                                    $33, $30, $3D, $4A, $10, $5F, $4B, $25, $34,
                                    $2F, $2E, $39, $40, $1A, 6, $61, $4C, $3B,
                                    $41, $42, $26, $22, $29, $19, 4, $62, $46,
                                    $14, $15, $17, $4D, $4F, $52, $20, 3, $53,
                                    8, $A, $B, $D, $E, $60, $5E, $5C, $54);
  coda: Array [0..7] of Char;
  rng_vec : array [0..LEN - 1] of Cardinal;
  rng_tap : Cardinal;
  rng_feed: Cardinal;

function isrand(_seed: Integer): Cardinal;
var
  seed,lo,hi,x: Cardinal;
  i: Integer;
begin
  seed := _seed;
  seed := seed mod M;
  if seed < 0 then Inc(seed,M);
  if seed = 0 then seed := 89482311;
  x := seed;
  i := -20;
  while i < LEN do
  begin
    hi := x div Q;
    lo := x mod Q;
    x := A*lo - R*hi;
    if x < 0 then Inc(x, M);
    if i >= 0 then rng_vec[i] := x;
    Inc(i);
  end;
  Result:= x;
end;

function lrand: Integer;
begin
  Dec(rng_tap);
  Dec(rng_feed);
  Result := (rng_vec[rng_feed] + rng_vec[rng_tap]) and MASK;
  rng_vec[rng_feed] := Result;
end;

procedure Calculate_P1(IMEI: String; var StrNCK: String);
var
  i, v3, v4, v5, v6, v8, v9, v10, v11, v12, v14: Integer;
  v16: Array [0..7] of Byte;
  v17: Array [0..7] of Byte;
begin
  v4 := StrToInt(Copy(IMEI, 9, 6)) + 313944551;
  for i := 0 to 5 do
  begin
    v6 := v4 mod 10;
    v4 := v4 div 10;
    v17[5-i] := v6;
  end;
  v8 := (13 * v17[5] + 5 * v17[4] + 3 * v17[3] + 1553 * v17[2] + 23 * v17[1] + 177 * v17[0]) mod 99999;
  for i := 7 downto 6 do
  begin
    v10 := v8 mod 10;
    v8 := v8 div 10;
    v17[i] := v10;
  end;
  v16[0] := Table_00[v17[0]];
  v16[1] := Table_01[v17[1]];
  v16[2] := Table_10[v17[2]];
  v16[3] := Table_11[v17[6]];
  v11 := Table_2[(10 * v17[3]) + v17[4]] - 1;
  v16[4] := v11 div 10;
  v16[5] := v11 mod 10;
  v12 := Table_2[99 - ((10 * v17[7]) + v17[5])] - 1;
  v16[6] := v12 div 10;
  v16[7] := v12 mod 10;
  v3 := 0;
  for i := 0 to 7 do
  begin
    v14 := (v16[i] shl (4 * i)) or v3;
    v3 := v14;
  end;
  isrand(v3);
  rng_tap := LEN;
  rng_feed := LEN-TAP;
  for i := 0 to 7 do
    coda[i] := Chr(lrand mod 10 + 48);
  StrNCK := coda;
end;

end.

sana makuha nyo kung pano paganahin hehe :D

br
freddy
 
Back
Top