Atom-128 algorithm in C#
Encode method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | public static string Atom128Encode(string input) { string key = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"; StringBuilder result = new StringBuilder(); int i = 0; int[] indexes = new int[4]; int[] chars = new int[3]; do { chars[0] = i + 1 > input.Length ? 0 : (int)input[i++]; chars[1] = i + 2 > input.Length ? 0 : (int)input[i++]; chars[2] = i + 3 > input.Length ? 0 : (int)input[i++]; indexes[0] = chars[0] >> 2; indexes[1] = ((chars[0] & 3) << 4) | (chars[1] >> 4); indexes[2] = ((chars[1] & 15) << 2) | (chars[2] >> 6); indexes[3] = chars[2] & 63; if ((char)chars[1] == 0) { indexes[2] = 64; indexes[3] = 64; } else if ((char)chars[2] == 0) { indexes[3] = 64; } foreach (int index in indexes) { result.Append(key[index]); } } while (i < input.Length); return result.ToString(); } |
Decode method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | public static string Atom128Decode(string input) { string key = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"; StringBuilder result = new StringBuilder(); int[] indexes = new int[4]; int[] chars = new int[3]; int i = 0; do { indexes[0] = key.IndexOf(input[i++]); indexes[1] = key.IndexOf(input[i++]); indexes[2] = key.IndexOf(input[i++]); indexes[3] = key.IndexOf(input[i++]); chars[0] = (indexes[0] << 2) | (indexes[1] >> 4); chars[1] = (indexes[1] & 15) << 4 | (indexes[2] >> 2); chars[2] = (indexes[2] & 3) << 6 | indexes[3]; result.Append((char)chars[0]); if (indexes[2] != 64) result.Append((char)chars[1]); if (indexes[3] != 64) result.Append((char)chars[2]); } while (i < input.Length); return result.ToString(); } |
Usage:
1 2 3 4 5 | // Results to LxrkpIQu0IHtOxSC+qCC+bCC string encodedString = Atom128Encode("fluxbytes.com"); // Results to fluxbytes.com string decodedString = Atom128Decode(encodedString); |
Internet Explorer 11 Developer Preview for Windows 7 or higher
Microsoft has released a Developer Preview version for Internet Explorer 11. Internet Explorer 11 was only available as part of Windows 8.1 Preview till now but this release makes it available for Windows 7 and Windows Server 2008 R2 as well.
You can find the download links for the English version below. If you are looking for different languages visit http://windows.microsoft.com/en-us/internet-explorer/ie-11-worldwide-languages where you can find the download links for numerous other languages.
Download links removed. Read below.
Note: Internet Explorer 11 final version is now available. See
Internet Explorer 11 is now available for Windows 7 instead.
Posted in Microsoft, Software Releases.
Tagged developer preview, Internet Explorer, Internet Explorer 11, Microsoft
Microsoft Office 2010 SP2
Microsoft has released Service Pack 2 (SP2) for their Office 2010 suite.
This update contains various bug fixes as well as improvements to the suite’s stability and performance.
Overview of Office 2010 SP2 improvements
Excel 2010 SP2
- Improves the overall stability, performance, and compatibility with other versions of Excel. For a more detailed list of specific issues that the service pack fixes, please download a version of the workbook that is available below.
- Fixes issues in which the performance of Excel decreases, and Excel file sizes become larger when additional built-in styles are copied during the duplication of data between different Excel instances.
- Fixes an issue in which data validation lists that contain comma signs (,) are broken in an .xlsx or .xlsb file. This issue occurs when you set the user locale to a location that does not use comma signs (,) to separate the lists. For example, Germany uses semicolons (;) to separate the lists. When you set Germany as the location, data validation lists that contain commas are all broken.
- Fixes an issue in which an .xlsx file created in Microsoft Office 2013 that contains an App bound to a table is corrupted on save. Additionally, it addresses the issue in which all Agave formulas in the workbook sheet are removed from the file.
Outlook 2010 SP2
- Fixes the issue regarding the message size of certain long email messages. Additionally, it fixes an issue that occurs when you perform a spell check before you send an email message.
PowerPoint 2010 SP2
- Improves the quality of videos in a presentation after the videos are optimized or compressed by PowerPoint.
- Fixes issues that occur when you co-author a presentation with other users at the same time.
- Fixes an issue in which Mozilla FireFox crashes when you try to view a presentation in PowerPoint Web App on a Mac computer that has Microsoft Silverlight 3 or Silverlight 4 installed.
Word 2010 SP2
- Fixes issues regarding bookmarks, fields, track changes, templates, tables, object wrapping, autocorrect options, and email addresses. Additionally, it fixes general reliability issues that occur when you post a blog entry on Microsoft SharePoint Server 2013 and Microsoft Office 365 blogs.
Posted in Microsoft, Software Updates.
Force Firefox to prompt to save mp3 and videos rather than play them in the browser
You might have noticed that in a lot of Firefox versions the browser starts playing .mp3, or other sound/video formats, directly in the browser rather than displaying a prompt asking if you want to save the file. Moreover, setting the format under Tools > Options > Applications
to either Always ask or Save File doesn’t really change this behavior.
Luckily there is a workaround to alter this functionality.
- Enter about:config in your Firefox’s address bar and press enter.
- Search for media.windows-media-foundation.enabled
- Set the value of the property to false
And you are done. Now everytime you click on an .mp3 file or any other format that is supported by Windows media foundation you should get a prompt asking you if you want to save the file or if you want to open it directly.
Posted in Software Tips.
Tagged firefox, media.windows-media-foundation.enabled, Mozilla firefox, mp3
Turn monitor on/off in C#
The following snippet will allow you to change your monitor’s state to either off/on or standby mode. Unlike other methods this one works on Windows 7 as well (tested under Windows 7 64bit).
The first step is to include in your class the following code:
1 2 3 4 5 6 7 8 9 10 11 12 | [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); private int SC_MONITORPOWER = 0xF170; private int WM_SYSCOMMAND = 0x0112; enum MonitorState { ON = -1, OFF = 2, STANDBY = 1 } |
This will allow us to send a WM_SYSCOMMAND
message using SendMessage
to alter the state of the monitor.
Finally, add the method which we will be calling when we want to change the monitor’s state:
1 2 3 4 | public void SetMonitorState(MonitorState state) { SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, (int)state); } |
Simply call the SetMonitorState
method with the desirable state you want to change your monitor’s state to.
Usage:
1 | SetMonitorState(MonitorState.OFF); |
Keep in mind that the SC_MONITORPOWER
commands supports devices that have power-saving features, so depending on the monitor’s brand/drivers/firmware results might vary.
Posted in C#.
Tagged C#, csharp, HWND_BROADCAST, monitor, SC_MONITORPOWER, snippet, winforms, WM_SYSCOMMAND