Ver Mensaje Individual
  #4  
Antiguo 05-07-2010
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.286
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Ok. En tu caso veo que no hay etiquetas, porque eso es todo el fichero.
A veces al contener más cosas se "dividen" las partes utilizando etquetas.

Lo primero es comprobar que esos datos es algo "con sentido". Para hacer la prueba fácil puedes probar alguna de las múltiples Webs online que te permiten "decodificar" ese churro de caracteres. Para ello busca en Google "Decode Base64" y encontrarás muchas.
Por ejemplo, si pruebas aquí, con el texto que has colocado, verás que la decodificación devuelve el siguiente texto:

Código:
%PDF-1.4
%����
%Created by Wnv/EP PDF Tools v6.0
1 0 obj
<<
/PageMode /UseNone
/ViewerPreferences 2 0 R
/Type /Catalog
/PageLayout /OneColumn
/Pages 3 0 R
>>
...
Que tiene pinta de ser cláramente un PDF. Prueba con algunos textos y deberías poder grabar el resultado en un PDF y abrirlo sin problemas.

Una vez que hayas comprobado que se traduce correctamente, hay que conseguir hacerlo desde Delphi. Al igual que hay muchas páginas de Decede Base64, también hay bastantes "códigos" en Delphi para hacerlo.

Si colocas un formulario con 2 memos y un botón, puedes probar un código como este:

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
const
  CRYPT_STRING_BASE64 = 1;  {Irene. prueba de desencriptado}  

procedure StrToStream(Str: String; Stream: TStream);

implementation

{$R *.dfm}

// Irene. Prueba de desencriptado...
function CryptBinaryToString(pbBinary: PByte; cbBinary: DWORD; dwFlags: DWORD;
  pszString: PChar; var pcchString: DWORD): BOOL; stdcall;
  external 'Crypt32.dll' name 'CryptBinaryToStringA';

function CryptStringToBinary(pszString: PChar; cchString: DWORD; dwFlags: DWORD;
  pbBinary: PByte; var pcbBinary: DWORD; pdwSkip: PDWORD;
  pdwFlags: PDWORD): BOOL; stdcall;
  external 'Crypt32.dll' name 'CryptStringToBinaryA';

procedure StrToStream(Str: String; Stream: TStream);
var
  Buffer: PByte;
  Count: DWORD;
begin
  Count:= 0;
  if CryptStringToBinary(PChar(Str),Length(Str),CRYPT_STRING_BASE64,nil,Count,
    nil,nil) then
  begin
    GetMem(Buffer,Count);
    try
      if CryptStringToBinary(PChar(Str),Length(Str),CRYPT_STRING_BASE64,Buffer,
        Count,nil,nil) then
        Stream.WriteBuffer(Buffer^,Count);
    finally
      FreeMem(Buffer);
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Stream: TFileStream;
  NUevoFich:string;
begin
  // decode
  NuevoFich := 'r:\test.pdf';
  Stream:= TFileStream.Create(NuevoFich, fmCreate);
  try
    StrToStream(Memo1.Lines.Text, Stream);

  finally
    Stream.Free;
  end;

  // Sin embargo la firma no...
  Memo2.Lines.LoadFromFile(NuevoFich);
end;

end.

El memo1 con el trexto original, el que has puesto más arriba, por ejemplo, y en el botón la llamada a la decodificación.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita