Mega Anaska

Mega Anaska

  • NA
  • 144
  • 35.9k

Decode base 64 to Image url

Sep 7 2019 12:48 AM
Hi guys I have script to encrypt url image to base64 like :
  1. public String ConvertImageURLToBase64(String url)  
  2. {  
  3. StringBuilder _sb = new StringBuilder();  
  4. Byte[] _byte = this.GetImage(url);  
  5. _sb.Append(Convert.ToBase64String(_byte, 0, _byte.Length));  
  6. return _sb.ToString();  
  7. }  
  8. private byte[] GetImage(string url)  
  9. {  
  10. Stream stream = null;  
  11. byte[] buf;  
  12. try  
  13. {  
  14. WebProxy myProxy = new WebProxy();  
  15. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);  
  16. HttpWebResponse response = (HttpWebResponse)req.GetResponse();  
  17. stream = response.GetResponseStream();  
  18. using (BinaryReader br = new BinaryReader(stream))  
  19. {  
  20. int len = (int)(response.ContentLength);  
  21. buf = br.ReadBytes(len);  
  22. br.Close();  
  23. }  
  24. stream.Close();  
  25. response.Close();  
  26. }  
  27. catch (Exception exp)  
  28. {  
  29. buf = null;  
  30. }  
  31. return (buf);  
  32. }  
Now I want to decode base64 to url image . is it possible? if possible can you give me reference, please? thanks. I am Mega 

Answers (1)