Solved: <pre>public string decoder(string data) { string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; char o1, o2, o3; int h1, h2, h3, h4, bits, i = 0; string enc = ""; do { h1 = b64.IndexOf(data.Substring(i++, 1)); h2 = b64.IndexOf(data.Substring(i++, 1)); h3 = b64.IndexOf(data.Substring(i++, 1)); h4 = b64.IndexOf(data.Substring(i++, 1)); bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; o1 = (char)(bits >> 16 & 0xff); o2 = (char)(bits >> 8 & 0xff); o3 = (char)(bits & 0xff); if (h3 == 64) enc += new string(new char[] { o1 }); else if (h4 == 64) enc += new string(new char[] { o1, o2 }); else enc += new string(new char[] { o1, o2, o3 }); } while (i < data.Length); return enc; } public string d(int key, string data) { int i; string strInput = decoder(data); StringBuilder strOutput = new StringBuilder(""); int intOffset = (key + 112) / 12; for (i = 4; i < strInput.Length; i++) { int thisCharCode = strInput[i]; char newCharCode = (char)(thisCharCode - intOffset); strOutput.Append(newCharCode); } return strOutput.ToString(); } </pre>
E3pO
Posts
-
Help converting java-script to C#. -
Help converting java-script to C#.Well, i got it to work only when the key is a negative number.. For some reason it's still not able to convert when data is a positive number. Example: (int key = 212, string data = "U0lra36DfImFkImOkImCW4OKj4h8hIdJfoqI") Output = {c¬a¬¬¬¬¬¬¬¬@¬¬¬¬a¬¬.c¬¬} Example2: (int key = -88, string data = "T1RXYmV0cHFkZ3R1MzQ1Ng==") Output = {crnobers1234} Code:
public string decode(int key, string data)
{
int i;
string strInput = base64Decode(data);
StringBuilder strOutput = new StringBuilder("");int intOffset = (key + 112) / 12; for (i = 4; i < strInput.Length; i++) { int thisCharCode = strInput\[i\]; char newCharCode = (char)(thisCharCode - intOffset); strOutput.Append(newCharCode); } return strOutput.ToString(); }
-
Help converting java-script to C#.Hello! i'm a bit baffled when it comes to converting this javascript over to C#... Any help would be appreciated! Thank you :) Here is the javascript:
function d(strInput) {
strInput = decoder(strInput);
var strOutput = "";
var intOffset = (key + 112) / 12;
for (i = 4; i < strInput.length; i++) {
thisCharCode = strInput.charCodeAt(i);
newCharCode = thisCharCode - intOffset;
strOutput += String.fromCharCode(newCharCode)
}
document.write(strOutput)
}And this is what i attempted at converting to C#.
public string decode(int key, string data) { int i; string strInput = base64Decode(data); string strOutput = ""; int intOffset = (key + 112) / 12; for (i = 4; i < strInput.Length; i++) { char thisLetter = strInput\[i\]; char thisCharCode = strInput\[i\]; int newCharCode = thisCharCode - intOffset; strOutput += new String(new char\[\]{Convert.ToChar(newCharCode)}); } return strOutput; }
-
Multiple bitmaps into one final image.Oh, I'm sorry. I need help with code to do that, That was just an example of what needs to happen. And here is code in VB i was working with awhile back, i'm not sure if it was ever finished.. loaded up in visual studio gives me the error Error 1 Overload resolution failed because no accessible 'DrawImage' can be called with these arguments: 'Public Sub DrawImage(image As System.Drawing.Image, x As Integer, y As Integer)': Value of type 'System.Drawing.Brush' cannot be converted to 'System.Drawing.Image'. 'Public Sub DrawImage(image As System.Drawing.Image, x As Single, y As Single)': Value of type 'System.Drawing.Brush' cannot be converted to 'System.Drawing.Image'. N:\XP\My Docs\My Documents\Visual Studio 2008\Projects\HaloVideo\****Video\Form1.vb 12 9 ****Video Dim img3 As New Bitmap(PictureBox1.Image.Height + PictureBox2.Image.Height, PictureBox1.Image.Width) Dim g As Graphics = Graphics.FromImage(img3) g.DrawImage(Brushes.Blue, 0, 0) g.DrawImage(PictureBox1.Image, 0, 0) g.DrawImage(PictureBox2.Image, PictureBox2.Image.Width + 1, 0) PictureBox3.Image = img3 But i need for C#, and i need it to actually do what i want it to do. lol I guess a way would to possibly have a blue background graphic and then overlay images ontop of it with 1 px distance from eachother?
-
Multiple bitmaps into one final image.Hello, I've been messing around with some code for a long time and haven't been able to figure out how do to this.. I've messed around with the System.Drawing.Bitmap, and bitmap graphics... What I need is to get all of the images from a video file (i can do this myself, unless it's super easy to render every frame of an avi file?) and place each image on one large bitmap. Each image has to be converted to a power of 2 dimension (256x256, 512x256,1024x512, etc) and placed 1 blue pixel apart. Here is an image example.. First image,