changed password generator to use a better randomness source
parent
f9fd0d578b
commit
1ca4cbc197
4
Makefile
4
Makefile
|
@ -1,5 +1,7 @@
|
|||
JSPKGMAN = "yarn"
|
||||
ROOTDIR = $(dir $(CURDIR))
|
||||
HEAD=$(shell git rev-parse --short HEAD)
|
||||
|
||||
|
||||
dev:
|
||||
$(JSPKGMAN) run vite dev
|
||||
|
@ -16,7 +18,9 @@ wasm-pack:
|
|||
|
||||
docker:
|
||||
podman build -t docker.io/jmbitci/crypttool .
|
||||
podman build -t docker.io/jmbitci/crypttool:$(HEAD) .
|
||||
podman push docker.io/jmbitci/crypttool
|
||||
podman push docker.io/jmbitci/crypttool:$(HEAD)
|
||||
|
||||
|
||||
#TODO get rid of -f and check whether files exist instead
|
||||
|
|
|
@ -4,3 +4,11 @@ This Project is more of a proof of concept than an actually useful Application,
|
|||
The Idea of this Project is to do all of the Encryption client-side using Javascript or WebAssembly, so the Website will work without any Server and can be packaged as a single html file and distributed this way.
|
||||
|
||||
Ideally, I would like for this to be able to en/decrypt any content. A nice to have Feature would be to make it work in a "self-extracting" way, so you could basically generate a html file that prompts you for a password and decrypts its content.
|
||||
|
||||
## Technology
|
||||
This website is essentially a frontend to the Browsers [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) cryptography API.
|
||||
|
||||
## TODO
|
||||
- Make sure the cryptography is sound
|
||||
- Configuration options (Password length, type)
|
||||
- Passhphrase option
|
||||
|
|
|
@ -6,3 +6,4 @@ export let encryptTarget = writable();
|
|||
export let decryptSource = writable();
|
||||
export let decryptDestination = writable<File>();
|
||||
export let errorMessage = writable<string>("");
|
||||
export let passwordLength = writable<number>(16);
|
|
@ -1,14 +1,23 @@
|
|||
import { writable} from 'svelte/store';
|
||||
import { passwordLength } from './generalStore';
|
||||
let length: number = 16;
|
||||
passwordLength.subscribe(value => {
|
||||
length = value;
|
||||
})
|
||||
|
||||
function generateRandomString(length: number): string {
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
const charCode = Math.floor(Math.random() * 62);
|
||||
result += String.fromCharCode(charCode + (charCode < 26 ? 65 : (charCode < 52 ? 71 : -4)));
|
||||
while (result.length < length) {
|
||||
const array = new Uint8Array(1);
|
||||
self.crypto.getRandomValues(array);
|
||||
const charCode: number = array[0];
|
||||
if ( 33 < charCode && charCode < 126 ) {
|
||||
result += String.fromCharCode(charCode + (charCode < 26 ? 65 : (charCode < 52 ? 71 : -4)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const password: string = generateRandomString(16);
|
||||
const password: string = generateRandomString(length);
|
||||
export let globalPassword = writable(password);
|
||||
|
||||
|
|
Loading…
Reference in New Issue