For educational reasons I've decided to create my own CA. Here is what I learned.
Lets get some context first.
| function Blockchain() { | |
| const blocks = this.blocks = [] | |
| const getBlockId = (i) => blocks[i] && blocks[i].id || '00000000' | |
| function hash(str) { | |
| const hash = Array(8).fill(0); | |
| for (let i = 0; i < str.length; i++) | |
| hash[i % 8] ^= str.charCodeAt(i) | |
| return hash.map((e) => e % 10).join('') |
| # change all .js files to .ts | |
| find . -name '*.js' -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \; |
| #!/usr/bin/env bash | |
| set -e | |
| if [ -z "$1" ] | |
| then | |
| echo "Missing destination file parameter." | |
| echo "Usage: $0 path/to/dest" | |
| echo "Example: $0 /srv/registry/security/htpasswd" | |
| exit 1; |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
| } | |
| parse_path() { | |
| if [ / = $PWD ]; then | |
| echo "/"; | |
| return; | |
| fi |
| import 'reflect-metadata'; | |
| interface Type<T> { | |
| new(...args: any[]): T; | |
| } | |
| export const Injector = new class extends Map { | |
| resolve<T>(target: Type<T>): T { | |
| let tokens = Reflect.getMetadata('design:paramtypes', target) || []; |
| import { Cache } from './cache.decorator'; | |
| class Test { | |
| seed; | |
| constructor(seed?) { | |
| this.seed = seed || Math.random(); | |
| } | |
| @Cache() |
| #Complete la ligne depuis l'historique plutot que d'ecraser la frappe en cours | |
| bind '"\e[A": history-search-backward' | |
| bind '"\e[B": history-search-forward' | |
| PS1="$(if [[ ${EUID} == 0 ]]; | |
| then echo '\[\033[01;31m\]\u\[\033[01;0m\]@\h'; | |
| else echo '\[\033[01;33m\]\u\[\033[01;0m\]@\h'; fi)\[\033[01;36m\] \w/ \[\033[01;0m\]\\$ \[\033[01;0m\]" | |
| PS2='> ' | |
| PS3='> ' | |
| PS4='+ ' |
| /** | |
| * @type [[[number], [[string]]]] | |
| */ | |
| const tests = [ | |
| [[0, 1, 0], [['tea', 'aba', 'obj'], ['eat', 'aaa', 'job']]], | |
| [[3], [['zzz'], ['aaa']]], | |
| [[0], [['zzx'], ['xzz']]], | |
| [[1, 1], [['zzx', 'xza'], ['xza', 'zzx']]], | |
| [[0, 1], [['azx', 'xza'], ['xza', 'zzx']]], | |
| [[-1, 0], [['azzz', 'xza'], ['xza', 'zax']]], |