Skip to content

Instantly share code, notes, and snippets.

@quentinproust
quentinproust / aes-gcm-encryption.md
Last active May 28, 2021 08:53
AES GCM Encryption

The parameters here are :

Authentication tag length = 128 bits (8 bytes)

According to the Web Crypto specification this must have one of the following values: 32, 64, 96, 104, 112, 120, or 128. The AES-GCM specification recommends that it should be 96, 104, 112, 120 or 128, although 32 or 64 bits may be acceptable in some applications: Appendix C of the specification provides additional guidance here.

IV length = 16 bytes

The AES-GCM specification recommends that the IV should be 96 bits long, and typically contains bits from a random number generator

@quentinproust
quentinproust / which-app-using-post.psh
Last active August 4, 2020 08:19
Find which app is using a port
netstat -aon | findstr '8080'
# > TCP 10.0.0.6:51834 10.0.4.44:8080 ESTABLISHED 14252
tasklist | findstr '14252'
# > chrome.exe 14252 Console 1 39?728 Ko
Stop-Process -F -Id 14252
@quentinproust
quentinproust / Slf4jLoggerExtension.kt
Created January 22, 2020 14:58
Kotlin - Slf4j Logger Extensions
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.lang.Exception
inline fun <reified T> T.logger(): Logger = LoggerFactory.getLogger(T::class.java)
fun Logger.traceWithContext(format: String, vararg contextParams: Pair<String, Any>, exception: Exception? = null) {
val paramsFormat = contextParams.joinToString(",") { "${it.first}={}" }
val paramsArgs = contextParams.map { it.second }.let {
when (exception) {

Keybase proof

I hereby claim:

  • I am quentinproust on github.
  • I am quentinproust (https://keybase.io/quentinproust) on keybase.
  • I have a public key ASB8iC33-9b2vxTkeUdSU3g-3XkvewD6tVdn2ax6HHFMZwo

To claim this, I am signing this object:

@quentinproust
quentinproust / gist:f02e7226ddc2ee32b104117f544a653f
Created January 17, 2019 14:26
Auth client/server with SSL certificates

Nous allons traiter ici d'un appel https où le client doit aussi s'authentifier en SSL.

Il y a deux parties :

  • l'authentification du serveur : comme lors de tout appel https, le client doit authentifier le serveur par rapport aux autorités de confiance qu'il connait. Pour java, les autorités de confiance par défaut sont stockées dans le fichier $JAVA_HOME/jre/lib/security/cacerts. Il s'agira de vérifier que le certificat transmis par le serveur a bien été émis par une de ces autorités.
  • l'authentification du client : on va "signer" l'appel https avec une clé privé pour que le serveur authentifie lui aussi le client.

Signification des erreurs possibles

Pour simplifier l'identification des problèmes, voici les erreurs qu'on peut obtenir en Java lors des appels et la partie posant problème.

@quentinproust
quentinproust / useful_pg.md
Created January 8, 2019 09:03
Some useful Postgresql commands

Create new database

createuser -h localhost --username=postgres -w -S --pwprompt <usename>
$ Saisir le mot de passe pour le nouveau rôle

createdb --owner=<usename> --host=localhost --username=<usename> <dbname>

Cloning a database

@quentinproust
quentinproust / debug-popup.js
Created October 13, 2016 07:08
Javascript popup to debug : add a small popup to the window with a value. I use it in a bookmark after minifying it.
(function() {
var text = "Somme des salaires : ";
// popup
var x = document.createElement("div");
x.appendChild(document.createTextNode(text));
x.setAttribute("style", "border: 3px solid black; background: white; height: 30px; width: 200px; padding: 15px; position: fixed; top: 20%; right: 2%;");
var close = document.createElement("a");
close.appendChild(document.createTextNode("X"));
@quentinproust
quentinproust / remove-duplicate-files.ps1
Created June 5, 2015 16:19
Remove duplicate files with powershell
ls | Get-FileHash
| Group-Object -Property Hash
| Where-Object -Property Count -gt 1
| ForEach-Object { $_.Group.Path | select -First ($_.Count -1)}
| Remove-Item
@quentinproust
quentinproust / gist:6917959
Created October 10, 2013 13:03
XML validation using XSD
@Test
public void testValiderXsd() throws Exception {
String fichierXsd = "schema.xsd";
String fichierXml = "input.xml";
List<SAXParseException> errors = validateXMLSchema(fichierXsd, fichierXml);
if(CollectionUtils.isNotEmpty(errors)) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("Le fichier xml n'est pas valide.\n");
@quentinproust
quentinproust / UnsetWalker.java
Created January 10, 2013 21:03
Class to check that all properties are defined with values. It's not perfect but should work for simple case.
/**
* Unset walker class
*/
package walker;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;