mercredi 19 décembre 2018

C# / Generate a 1024 bits symmetric key for HMAC-SHA256

Here is the way to generate a symmetric key for HMAC-SHA256 encryption, that is needed, for example, in using JWT Security Tokens when providing a REST API :

        private static void GenerateEncryptionKey()
        {
            RNGCryptoServiceProvider cryptoProvider = new RNGCryptoServiceProvider();
            byte[] keyForHmacSha256 = new byte[64];
            cryptoProvider.GetNonZeroBytes(keyForHmacSha256);
            StringBuilder hex = new StringBuilder(keyForHmacSha256.Length * 2);
            foreach (byte b in keyForHmacSha256)
            {
                hex.AppendFormat("{0:x2}", b);
            }
            Console.WriteLine(hex.ToString());
        }

An example of output is composed of 128 bytes, that means 128x8 bits, so 1024 bits :
"401b09eab3c013c48a54922bb802bec8fd531819211125f201d8b3727429090fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f59d3ed1"

You could then copy and paste this generated key into your Token Validation Handler if needed for this purpose...

jeudi 6 décembre 2018

jeudi 29 novembre 2018

How to install the KB2919355 update for Windows (Security update)

In order to install the KB2919355 update (for Windows 8.1 or Windows Server 2012 R2), you must have installed the KB2919442 update before.

This is mandatory when you want to install Microsoft SQL Server 2017 on a Windows Server 2012 R2 machine.


Commet installer la mise-à-jour Windows KB2919355 ?

Si vous avez des problèmes pour installer la mise-à-jour de sécurité KB2919355, sâchez qu'il faut installer préalablement la mise-à-jour KB2919442 avant de lancer l'installation de la KB2919355.

J'ai obtenu cette information sur la page suivante :
https://social.technet.microsoft.com/Forums/en-US/963711a4-e77c-418c-b088-ac54f5e5b4b3/server-2012-r2-unable-to-install-kb2919355?forum=winserver8gen

La mise-à-jour KB2919355 est nécessaire par exemple quand vous souhaitez installer Microsoft SQL Server 2017 sur une machine Windows Server 2012 R2.

mercredi 28 novembre 2018

How to manually uninstall SQL Server (2017) or any other application

1- Download the following executable file, msiinv.zip from :

https://onedrive.live.com/?authkey=%21ANs8Pr0aVhaT_qQ&cid=27E6A35D1A492AF7&id=27E6A35D1A492AF7%21910&parId=27E6A35D1A492AF7%21376&action=locate

Alternative download link :
https://ufile.io/wv3c3


2- Unpack this file in a temp folder (such as C:\tmp\)


3- In command line, launch powershell


4- In powershell enter :
c:\tmp\msiinv.exe -s | Select-String "SQL Server" -Context 0,1


5- Then you have a list of SQL Server related applications


6- Take each product code and for each one launch msiexe /x such as :
msiexec /x {327B1B40-2434-4DC5-9D4D-B9B24D4B2EDE}


7- Follow steps on screen each time you launch msiexec


8- Launch Regedt32 and delete SQL services in the following key : 
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services


mardi 27 novembre 2018

How to use ChromeDriver (PhantomJS) through Socks5 proxy in C# ?

Here is a sample project that can be opened with Visual Studio 2017, and that will be a basic sample showing how to connect to a remote website (ipleak.com) through a Socks5 proxy (default is 127.0.0.1:9150) :

Download at :
https://github.com/reuniware/SeleniumChromeDriverBase/blob/master/PhantomJsTest3-Socks5-Proxy.zip

Info at :
https://github.com/reuniware/SeleniumChromeDriverBase

lundi 26 novembre 2018

Exemple d'expression lambda en C++ 11

Expression lambda, exemple créé avec Visual Studio 2017

#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
auto p = [] (int a, int b) { cout << "a+b = " << (a+b) << endl; };
p(5,2);
return 0;
}



vendredi 23 novembre 2018