eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programming › Zaszyfrowane CAPICOMem, jak odszyfrować CryptoAPI?
Ilość wypowiedzi w tym wątku: 2

  • 1. Data: 2009-09-08 12:26:35
    Temat: Zaszyfrowane CAPICOMem, jak odszyfrować CryptoAPI?
    Od: "gosmo" <t...@m...pl>

    Witam, mam zaszyfrowane dane poniższym kodem:
    EncryptedData := CreateOleObject('CAPICOM.EncryptedData');
    try
    EncryptedData.Algorithm.KeyLength :=
    CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS;
    EncryptedData.Algorithm.Name := CAPICOM_ENCRYPTION_ALGORITHM_3DES;
    EncryptedData.Content := AString;
    EncryptedData.SetSecret(ASecret);
    Result := EncryptedData.Encrypt;
    finally
    EncryptedData := Null;
    end;

    Aby odszyfrować to za pomocą CryptoAPI wykombinowałem takiego potworka:

    function DecodeWC(AString: WideString; ASecret: WideString = ''):
    WideString;
    var
    hProv : Cardinal;
    hHash : Cardinal;
    hKey : Cardinal;
    dwBlobLen : Cardinal;
    pBuffer : PByte;
    begin
    if (not CryptAcquireContext(hProv, Nil, NIL, PROV_RSA_FULL,
    CRYPT_VERIFYCONTEXT)) and (not CryptAcquireContext(hProv, Nil, Nil,
    PROV_RSA_FULL, CRYPT_VERIFYCONTEXT OR CRYPT_NEWKEYSET)) then
    RaiseLastOSError
    else
    try
    if not CryptCreateHash(hProv, CALG_MD5, 0, 0, hHash) then
    RaiseLastOSError
    else
    try
    if not CryptHashData(hHash, PByte(@ASecret[1]), Length(ASecret) * 2,
    0) then RaiseLastOSError;
    if not CryptDeriveKey(hProv, CALG_3DES, hHash, 0, hKey) then
    RaiseLastOSError
    else
    try

    dwBlobLen := Length(AString) * 2;
    pBuffer := PByte(@AString[1]);
    if not CryptDecrypt(hKey, 0, True, 0, pBuffer, dwBlobLen) then
    RaiseLastOSError;
    finally
    CryptDestroyKey(hKey);
    end;
    finally
    CryptDestroyHash(hHash);
    end;
    finally
    CryptReleaseContext(hProv, 0);
    end;
    end;

    Ale mimo, że używałem chyba wszystkich możliwych algorytmów hashujących to
    nadal dostaję komunikat złych danych przy CryptDecrypt.
    Jak odszyftować te dane za pomocą CryptoAPI?




  • 2. Data: 2009-09-10 20:13:35
    Temat: Re: Zaszyfrowane CAPICOMem, jak odszyfrować CryptoAPI?
    Od: Real Hacker <r...@m...com>

    gosmo pisze:
    > Witam, mam zaszyfrowane dane poniższym kodem:
    > EncryptedData := CreateOleObject('CAPICOM.EncryptedData');
    > try
    > EncryptedData.Algorithm.KeyLength :=
    > CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS;
    > EncryptedData.Algorithm.Name := CAPICOM_ENCRYPTION_ALGORITHM_3DES;
    > EncryptedData.Content := AString;
    > EncryptedData.SetSecret(ASecret);
    > Result := EncryptedData.Encrypt;
    > finally
    > EncryptedData := Null;
    > end;
    >
    > Aby odszyfrować to za pomocą CryptoAPI wykombinowałem takiego potworka:
    >
    > function DecodeWC(AString: WideString; ASecret: WideString = ''):
    > WideString;
    > var
    > hProv : Cardinal;
    > hHash : Cardinal;
    > hKey : Cardinal;
    > dwBlobLen : Cardinal;
    > pBuffer : PByte;
    > begin
    > if (not CryptAcquireContext(hProv, Nil, NIL, PROV_RSA_FULL,
    > CRYPT_VERIFYCONTEXT)) and (not CryptAcquireContext(hProv, Nil, Nil,
    > PROV_RSA_FULL, CRYPT_VERIFYCONTEXT OR CRYPT_NEWKEYSET)) then
    > RaiseLastOSError
    > else
    > try
    > if not CryptCreateHash(hProv, CALG_MD5, 0, 0, hHash) then
    > RaiseLastOSError
    > else
    > try
    > if not CryptHashData(hHash, PByte(@ASecret[1]), Length(ASecret) * 2,
    > 0) then RaiseLastOSError;
    > if not CryptDeriveKey(hProv, CALG_3DES, hHash, 0, hKey) then
    > RaiseLastOSError
    > else
    > try
    >
    > dwBlobLen := Length(AString) * 2;
    > pBuffer := PByte(@AString[1]);
    > if not CryptDecrypt(hKey, 0, True, 0, pBuffer, dwBlobLen) then
    > RaiseLastOSError;
    > finally
    > CryptDestroyKey(hKey);
    > end;
    > finally
    > CryptDestroyHash(hHash);
    > end;
    > finally
    > CryptReleaseContext(hProv, 0);
    > end;
    > end;
    >
    > Ale mimo, że używałem chyba wszystkich możliwych algorytmów hashujących to
    > nadal dostaję komunikat złych danych przy CryptDecrypt.
    > Jak odszyftować te dane za pomocą CryptoAPI?
    >
    >
    >
    >
    >
    > ---
    > avast! antywirus: Przychodzace wiadomosc czysta.
    > Baza sygnatur wirusow (VPS): 090910-0, 2009-09-10
    > Przetestowano na: 2009-09-10 22:13:16
    > avast! - copyright (c) 1988-2009 ALWIL Software.
    > http://www.avast.com
    >
    >
    >
    Zaszyfruj sobie mózg, AES-em 256.


    ---
    avast! antywirus: Wychodzace wiadomosc czysta.
    Baza sygnatur wirusow (VPS): 090910-0, 2009-09-10
    Przetestowano na: 2009-09-10 22:13:36
    avast! - copyright (c) 1988-2009 ALWIL Software.
    http://www.avast.com



strony : [ 1 ]


Szukaj w grupach

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: