1
0
Fork 0
This commit is contained in:
Michaël Lemaire 2022-05-31 20:32:48 +02:00
parent 74f4be962e
commit 6f0d4cabcd
6 changed files with 35 additions and 13 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
deno.d.ts
.vscode
.local
.output
web/*.js

View File

@ -1,3 +1,3 @@
{
"deno.enable": true
"deno.enable": true
}

2
cli.ts
View File

@ -1,4 +1,4 @@
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-env
#!./run
import { showZenityUI } from "./ui/zenity.ts";
if (import.meta.main) {

1
config/run.flags Normal file
View File

@ -0,0 +1 @@
--allow-env=CWD,HOME --allow-read=.local/config.json --allow-run=zenity,xclip

View File

@ -53,15 +53,15 @@ export class Hasher {
}
/**
* Get the default params
*/
* Get the default params
*/
static getDefaultParams(): HashParams {
return { mode: HashOutputMode.ALNUM, length: 12 };
}
/**
* Parse hashing params (character class and length) from a string
*/
* Parse hashing params (character class and length) from a string
*/
static parseParams(input: string): HashParams {
let params = this.getDefaultParams();
@ -84,8 +84,8 @@ export class Hasher {
}
/**
* Try hashing an input string.
*/
* Try hashing an input string.
*/
tryHashing(input: string): string | null {
if (input.length > 1 && input.charAt(input.length - 1) == "#") {
let base = input.substr(0, input.length - 1);
@ -112,8 +112,8 @@ export class Hasher {
}
/**
* Get a final hashed password, from a list of options.
*/
* Get a final hashed password, from a list of options.
*/
getHash(base: string, site: string, params: HashParams): string {
// Hash the site name against the private key, to obtain a site key
let site_key = this.generateHashWord(
@ -268,7 +268,7 @@ export class Hasher {
s += sInput.substring(i, i + j);
}
s += String.fromCharCode((seed + i) % 26 + 65);
i += (j + 1);
i += j + 1;
}
if (i < sInput.length) {
@ -296,7 +296,7 @@ export class Hasher {
s += sInput.substring(i, i + j);
}
s += String.fromCharCode((seed + sInput.charCodeAt(i)) % 10 + 48);
i += (j + 1);
i += j + 1;
}
if (i < sInput.length) {

19
run Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Simplified run tool for deno commands
if test $# -eq 0
then
echo "Usage: $0 [file or command]"
exit 1
elif echo $1 | grep -q '.*.ts'
then
denocmd=run
denoargs=$1
shift
else
denocmd=$1
shift
fi
denoargs="$(cat config/$denocmd.flags 2> /dev/null) $denoargs $@"
exec deno $denocmd $denoargs