source: extensions/PiwigoLib/PiwigoLib/Proxy/Helper/PwgBase64Helper.cs @ 11890

Last change on this file since 11890 was 11890, checked in by bayral, 13 years ago

First draw of pwg.image.add and pwg.imae.addtrunck.
addtrunck seem to be ok, but image.add return server error 500.

File size: 1.2 KB
Line 
1using System;
2using System.Text;
3using System.Security.Cryptography;
4using System.IO;
5
6namespace Com.Piwigo.Lib.Proxy.Helper
7{
8    internal static class PwgBase64Helper
9    {
10        internal static string base64Encode(byte[] encData_byte)
11        {
12            try
13            {
14                string encodedData = Convert.ToBase64String(encData_byte);
15                return encodedData;
16            }
17            catch (Exception e)
18            {
19                throw new Exception("Error in PwgBase64Helper : " + e.Message,e);
20            }
21        }
22
23        internal static string GetphpMd5Sum(FileStream s)
24        {
25            MD5 md5 = new MD5CryptoServiceProvider();
26            byte[] hash = md5.ComputeHash(s);
27            // Build the final string by converting each byte
28            // into hex and appending it to a StringBuilder
29            string ret = "";
30            foreach (byte a in hash) {
31                if (a<16)
32                ret += "0" + a.ToString ("x");
33                else
34                ret += a.ToString ("x");
35            }
36
37            // And return it
38            return ret;
39        }
40    }
41}
Note: See TracBrowser for help on using the repository browser.