delphi4arab منتديات دلفي للعرب
تحويل كود c الى الدالفى - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : تحويل كود c الى الدالفى (/showthread.php?tid=1644)



تحويل كود c الى الدالفى - hanipino - 11-02-2010

السلام عليكم

اخوانى احتاج الى تحويل هدا الكود الى وحدة (Pas) دالفى .


تحويل كود c الى الدالفى - محمد عبد العزيز - 11-02-2010


لامر ليس صعب، لا تحاول تحويله حرفيا
اولا اقراء وافهم ما يفعله ثم برمج مثله
وبالتوفيق



تحويل كود c الى الدالفى - hanipino - 11-02-2010

ساحاول و اد لم انجح ساعود . Smile


تحويل كود c الى الدالفى - kachwahed - 11-02-2010

وعليكم السلام ورحمة الله
باستخدام بعض برامج التحويل
النتيجة سيئة جدا في المرفقات :kick:



تحويل كود c الى الدالفى - hanipino - 11-02-2010

ما هادا اخى كاش واحد هههه لم افم شىء :laugh:

الله اعلم ما يجب تحويلة هو هاتين الدالتين فقط
PHP كود :
u8 hex2byte(u8 *hex) {
    static const 
u8 hextable[256] =
        
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x00\x00\x00\x00\x00\x00"
        "\x00\x0a\x0b\x0c\x0d\x0e\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x0a\x0b\x0c\x0d\x0e\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
        "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
;

    return((
hextable[hex[0]] << 4) | hextable[hex[1]]);
}



u8 *camfrog_pwd(u8 *pwd, u8 *clsid) {
    
AES_KEY aes_ctx;
    
int     i,
            
pwdlen,
            
clsidlen;
    static const 
u8 key[16] = "CamFrogMCU DLL01";

    for(
i = 0; pwd[i << 1]; i++) {
        
pwd[i] = hex2byte(pwd + (i << 1));
    }
    
pwdlen = i;

    if(
clsid) {
        for(
i = 0; clsid[i << 1]; i++) {
            
clsid[i] = hex2byte(clsid + (i << 1));
        }
        
clsidlen = i;

        for(
i = 0; i < pwdlen; i++) {
            
pwd[i] ^= clsid[i % clsidlen];
        }
    }

    
AES_set_decrypt_key(key, sizeof(key) << 3, &aes_ctx);
    for(
i = 0; i < pwdlen; i += 16) {
        
AES_decrypt(pwd + i, pwd + i, &aes_ctx);
    }
    
pwd[i] = 0;
    return(
pwd);
} 
الباقى على ما اضن سهل و الله اعلم .


تحويل كود c الى الدالفى - kachwahed - 12-02-2010

إقتباس :ما هادا اخى كاش واحد هههه لم افم شىء
هذه أسميها++ Delphi :blink: لم يطوروها بعد Big Grin
الكود السابق باستخدام CAD-KAS C 2 Delphi Converterـ:
كود :
function inc2(var i:integer):integer;begin result:=i;inc(i);end; function incit(var i:integer;v:integer):integer;begin inc(i,v);result:=i;end; function xorit(var i:integer;v:integer):integer;begin i:=i xor v;result:=i;end; function hex2byte ( hex :^ u8 ; ) : u8 ; var ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' : ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($01)+''+chr($02)+''+chr($03)+''+chr($04)+''+chr($05)+''+chr($06)+''+chr($07)+''+chr($08)+''+chr($09)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($0a)+''+chr($0b)+''+chr($0c)+''+chr($0d)+''+chr($0e)+''+chr($0f)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($0a)+''+chr($0b)+''+chr($0c)+''+chr($0d)+''+chr($0e)+''+chr($0f)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+''+chr($00)+'' ; var hextable:array[0..256] of staticconstu8 ; begin hextable := begin result:= ( ( hextable [ hex [ 0 ] ] shl 4 ) or hextable [ hex [ 1 ] ] ) ; exit;end; end; function camfrog_pwd ( pwd :^ u8 ; clsid :^ u8 ; ) :^ u8 ; var key:array[0..16] of staticconstu8 ; clsidlen : int ; var pwdlen : int ; var i : int ; var aes_ctx : AES_KEY ; begin key := 'CamFrogMCU DLL01' ; i := 0 ; while ( pwd [ i < < 1 ] ) do begin begin pwd [ i ] := hex2byte ( pwd + ( i shl 1 ) ) ; end; inc2( i ) ; end; pwdlen := i ; if ( clsid ) then begin i := 0 ; while ( clsid [ i < < 1 ] ) do begin begin clsid [ i ] := hex2byte ( clsid + ( i shl 1 ) ) ; end; inc2( i ) ; end; clsidlen := i ; i := 0 ; while ( i < pwdlen ) do begin begin xorit ( pwd [ i ] , clsid [ i mod clsidlen ] ) ; end; inc2( i ) ; end; end; AES_set_decrypt_key ( key , sizeof ( key ) shl 3 , @ aes_ctx ) ; i := 0 ; while ( i < pwdlen ) do begin begin AES_decrypt ( pwd + i , pwd + i , @ aes_ctx ) ; end; incit ( i , 16 ; end; pwd [ i ] := 0 ) ; begin result:= ( pwd ) ; exit;end; end;
بالتوفيق أخي هانئ.
مرفق مثال مكتوب بلغة ++Delphi ـ Big Grin
المثال للمبرمج الألماني Beros