Skip to content

Instantly share code, notes, and snippets.

View duongdainghia's full-sized avatar

Nghia duongdainghia

View GitHub Profile
@duongdainghia
duongdainghia / main.go
Created May 11, 2021 03:52 — forked from treywelsh/main.go
golang dynamic xml unmarshalling mixed with fixed tags
package main
import (
"encoding/xml"
"fmt"
pkg "xml_unparsed/xmlmap"
//pkg "xml_unparsed/xmlslice"
)
@duongdainghia
duongdainghia / decrypt.go
Created September 25, 2020 11:29 — forked from apokalyptik/decrypt.go
Go RSA private key decryption example. Compatible with data encrypted via http://us3.php.net/openssl_public_encrypt
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"flag"
"fmt"
"io/ioutil"
@duongdainghia
duongdainghia / deencrypt_3des.go
Created September 18, 2020 08:05 — forked from wklken/deencrypt_3des.go
3des: encrypt with python & deencrypt with golang
package main
// reference: https://golang.org/pkg/crypto/des/
// reference: http://blog.studygolang.com/2013/01/go%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86%E4%B9%8Bdes/
import (
"crypto/cipher"
"crypto/des"
"encoding/base64"
"encoding/json"
@duongdainghia
duongdainghia / aes-256-cbc-test.js
Created September 17, 2020 08:19 — forked from brettscott/aes-256-cbc-test.js
AES 256 CBC encryption between Golang and Node JS
// Node v6.9.0
//
// TEST FILE (cut down for simplicity)
// To ensure Golang encrypted string can be decrypted in NodeJS.
//
let crypto;
try {
crypto = require('crypto');
<?php
function is_valid_luhn($number) {
settype($number, 'string');
$sumTable = array(
array(0,1,2,3,4,5,6,7,8,9),
array(0,2,4,6,8,1,3,5,7,9));
$sum = 0;
$flip = 0;
for ($i = strlen($number) - 1; $i >= 0; $i--) {
$sum += $sumTable[$flip++ & 0x1][$number[$i]];