Skip to content

Instantly share code, notes, and snippets.

@C0BR4cH
C0BR4cH / CryptoMagic.cs
Created November 2, 2018 10:30
Simple C# password hasher running from .NET 2.0 onward
using System;
using System.Security.Cryptography;
namespace SaltyCrypter
{
/// <summary>
/// Creates the salt and hash for a password
/// </summary>
public class CryptoMagic
{
@C0BR4cH
C0BR4cH / ReasonableExceptionMessages.java
Created February 9, 2018 14:29
Getting reasonable exception messages for com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException
public static <T extends Object> T deserialize(Path xmlFile, Class<T> clazz) {
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (T) unmarshaller.unmarshal(xmlFile.toFile());
} catch (Exception e) {
String message = "Error while deserializing XML.";
// Let's make some fancy magic to get understandable Exception messages!
if (e instanceof IllegalAnnotationsException) {
@C0BR4cH
C0BR4cH / MainWindow.xaml.cs
Created September 29, 2017 11:21
C# WPF Borderless Window with custom Titlebar
/// <summary>
/// Source initialization
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">args</param>
void Window_SourceInitialized(object sender, System.EventArgs e)
{
// Get handler for WPF window and hook into it
IntPtr windowHandle = (new WindowInteropHelper(this)).Handle;
HwndSource.FromHwnd(windowHandle).AddHook(new HwndSourceHook(WindowProc));
@C0BR4cH
C0BR4cH / OLEObjectUtil.cs
Created April 21, 2017 08:16
Removal of OLE header from images
public static class OLEObjectUtil
{
private const string BITMAP_OLE_HEADER = "BM";
private const string JPG_OLE_HEADER = "\u00FF\u00D8\u00FF";
private const string PNG_OLE_HEADER = "\u0089PNG\r\n\u001a\n";
private const string GIF_OLE_HEADER = "GIF8";
private const string TIFF_OLE_HEADER = "II*\u0000";
public static byte[] RemoveOleHeader(byte[] inputBytes)
{
@C0BR4cH
C0BR4cH / keybase.md
Created February 17, 2017 07:23
Proove for keybase.io

Keybase proof

I hereby claim:

  • I am c0br4ch on github.
  • I am cobra (https://keybase.io/cobra) on keybase.
  • I have a public key ASADxKryDVcvMaepOa3PfcABgbM-S-M80Tk7QJp3EfuiIAo

To claim this, I am signing this object: