Converter Base64 para String

19/07/2019

10

Boa tarde,

Estou consumindo um Webservice e recebo no retorno dele o conteúdo em base64.

Preciso decodificar este conteúdo para String e não estou conseguindo.

Exemplo de conteúdo que preciso decoficar:

SDAwMDAwMDEwMDMxOTExNjY5NjQ5NDAwMDEyMEFHVUlBUiBDT05TVFJVQ09FUyAgICAgICAgICAgICAgICAgICAgICAgICAwOTMyMDkwMjAwMDE4MA0KQzAwMDAwMDIxMTg2U0FWQVNTSSBTUE9SVCBHQVJERU4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOC8wNy8xOTAwOjAwQUdVQSAgIA0KVTAwMDAwMDMwMDUwMTAwMTAzMzIzMDAxMTQ5MDgwMDAwMDAwMDExMTAxDQpVMDAwMDAwNDAwNTAyMDAxMjExMTYwMDEzNjYzNDAwMDAwMDAwMTM4MTMNClUwMDAwMDA1MDA1MDMwMDA1MTc1NTAwMDU4MjU2MDAwMDAwMDAwNzU5NQ0KVTAwMDAwMDYwMDUwNDAwMDkyNDYzMDAxMTAzODcwMDAwMDAwMDE1NDcyDQpVMDAwMDAwNzAwNjAxMDAwNjkyMTIwMDA3NjIyMDAwMDAwMDAwMDc5NDUNClUwMDAwMDA4MDA2MDIwMDEyNzEwNzAwMTM5ODE0MDAwMDAwMDAxMTg3NA0KVTAwMDAwMDkwMDYwMzAwMDYwNTY2MDAwNjcxOTQwMDAwMDAwMDA3NjgyDQpVMDAwMDAxMDAwNjA0MDAwODQ0OTEwMDA5NTQwMTAwMDAwMDAwMTA2MzUNClUwMDAwMDExMDA3MDEwMDAwMzQ0OTAwMDA0MTI3MDAwMDAwMDAwMzU4MA0KVTAwMDAwMTIwMDcwMjAwMDg2NTk5MDAwOTA3MzEwMDAwMDAwMDA1OTYxDQpVMDAwMDAxMzAwNzAzMDAwNzM5MDIwMDA3OTk0NTAwMDAwMDAwMDcyNzkNClUwMDAwMDE0MDA3MDQwMDEyMzM0MjAwMTI5MTI3MDAwMDAwMDAwNzEwMQ0KVT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wMDE2MDQwMDAwMzIwMjAwMDIyNTQ5MDAwMDAwMDAxNjQ1Mw0KVTAwMDAwNTEwMTcwMTAwMDY0OTk1MDAwNzE5ODMwMDAwMDAwMDA3OTMxDQpVMDAwMDA1MjAxNzAyMDAxMjU4MDQwMDEzODA2MTAwMDAwMDAwMTE1NjQNClUwMDAwMDUzMDE3MDMwMDAyNTk3ODAwMDMwMzIwMDAwMDAwMDAwNjEwNg0KVTAwMDAwNTQwMTcwNDAwMDgwNTI1MDAwOTEwNjMwMDAwMDAwMDEwMzc5DQpVMDAwMDA1NTAxODAxMDAwNTUwMTgwMDA2MTkxNTAwMDAwMDAwMDc4NjgNClUwMDAwMDU2MDE4MDIwMDE0NjIwMzAwMTgwNDE0MDAwMDAwMDAyNjcwMw0KVTAwMDAwNTcwMTgwMzAwMTE4NzY2MDAxMzE4MTAwMDAwMDAwMDEyMTA3DQpVMDAwMDA1ODAxODA0MDAxMjIxOTIwMDEzMzM4MzAwMDAwMDAwMTA4MjkNClUwMDAwMDU5MDE5MDEwMDE3MzM2NTAwMTg3NTcxMDAwMDAwMDAxMjkwOA0KVTAwMDAwNjAwMTkwMjAwMDMxMDI0MDAwMzUzMTgwMDAwMDAwMDA2MDczDQpVMDAwMDA2MTAxOTAzMDAxNzI2NjYwMDE5NDk1NjAwMDAwMDAwMTg0ODMNClUwMDAwMDYyMDE5MDQwMDEwODg3MDAwMTIxNDU2MDAwMDAwMDAxMTc5MQ0KVDAwMDAwNjMwMDAwMDYw


Desde já agradeço.
Responder

Post mais votado

19/07/2019

Consegui resolver de maneira simples através do componente IdDecoderMIME do Indy.

Memo3.Lines.Text:= IdDecoderMIME1.DecodeString(Memo1.Lines.Text);

Sendo que no Memo1 está o conteúdo em base64 e o Memo3 recebe o arquivo já decodificado.
Responder

Mais Posts

02/08/2019

Fernando Ito

Muito bom Natanael Ferreira, obrigado por compartilhar a solução!


Um abraço,
ITO
Responder

02/08/2019

Fernando Ito

Outra forma de se resolver é a seguinte:

declarar a uses EncdDecd

e utilizar o método DecodeString

Memo3.Lines.Text := DecodeString(Memo1.Lines.Text);


Um abraço,
ITO
Responder
×
+1 DevUP
Acesso diário, +1 DevUP
Parabéns, você está investindo na sua carreira