1
0
Fork 0
mirror of https://github.com/iancoleman/shamir.git synced 2025-11-18 00:50:59 +00:00
This commit is contained in:
Blender Defender 2024-05-24 14:25:14 +02:00 committed by GitHub
commit 43ad7afb12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 3266 additions and 13619 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules/

1379
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

9
package.json Normal file
View file

@ -0,0 +1,9 @@
{
"scripts": {
"tailwind dev": "npx tailwindcss -i ./src/css/app_src.css -o ./src/css/app.css --watch",
"build": "npx tailwindcss -i ./src/css/app_src.css -o ./src/css/app.css && python compile.py"
},
"devDependencies": {
"tailwindcss": "^3.4.3"
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,30 +1,868 @@
input[type="number"] {
display: inline-block;
width: 70px;
/*
! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com
*/
/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
box-sizing: border-box;
/* 1 */
border-width: 0;
/* 2 */
border-style: solid;
/* 2 */
border-color: #e5e7eb;
/* 2 */
}
::before,
::after {
--tw-content: '';
}
/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
7. Disable tap highlights on iOS
*/
html,
:host {
line-height: 1.5;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
-moz-tab-size: 4;
/* 3 */
-o-tab-size: 4;
tab-size: 4;
/* 3 */
font-family: sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
/* 4 */
font-feature-settings: normal;
/* 5 */
font-variation-settings: normal;
/* 6 */
-webkit-tap-highlight-color: transparent;
/* 7 */
}
/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/
body {
margin: 0;
/* 1 */
line-height: inherit;
/* 2 */
}
/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/
hr {
height: 0;
/* 1 */
color: inherit;
/* 2 */
border-top-width: 1px;
/* 3 */
}
/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
/*
Remove the default font size and weight for headings.
*/
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: inherit;
}
/*
Reset links to optimize for opt-in styling instead of opt-out.
*/
a {
color: inherit;
text-decoration: inherit;
}
/*
Add the correct font weight in Edge and Safari.
*/
b,
strong {
font-weight: bolder;
}
/*
1. Use the user's configured `mono` font-family by default.
2. Use the user's configured `mono` font-feature-settings by default.
3. Use the user's configured `mono` font-variation-settings by default.
4. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp,
pre {
font-family: inherit;
font-size: inherit;
background: inherit;
border: inherit;
word-break: inherit;
white-space: pre-wrap;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
/* 1 */
font-feature-settings: normal;
/* 2 */
font-variation-settings: normal;
/* 3 */
font-size: 1em;
/* 4 */
}
.generated {
max-width: 100%;
overflow-wrap: break-word;
/*
Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
.part {
padding: 10px 0;
/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
.part:nth-of-type(2n+1) {
background-color: #F4F4F3;
sub {
bottom: -0.25em;
}
.part:nth-of-type(2n+0) {
background-color: #E9E8E6;
sup {
top: -0.5em;
}
/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/
table {
text-indent: 0;
/* 1 */
border-color: inherit;
/* 2 */
border-collapse: collapse;
/* 3 */
}
/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-feature-settings: inherit;
/* 1 */
font-variation-settings: inherit;
/* 1 */
font-size: 100%;
/* 1 */
font-weight: inherit;
/* 1 */
line-height: inherit;
/* 1 */
letter-spacing: inherit;
/* 1 */
color: inherit;
/* 1 */
margin: 0;
/* 2 */
padding: 0;
/* 3 */
}
/*
Remove the inheritance of text transform in Edge and Firefox.
*/
button,
select {
text-transform: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/
button,
input:where([type='button']),
input:where([type='reset']),
input:where([type='submit']) {
-webkit-appearance: button;
/* 1 */
background-color: transparent;
/* 2 */
background-image: none;
/* 2 */
}
/*
Use the modern Firefox focus style for all focusable elements.
*/
:-moz-focusring {
outline: auto;
}
/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/
:-moz-ui-invalid {
box-shadow: none;
}
/*
Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
vertical-align: baseline;
}
/*
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
}
/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type='search'] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/*
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/*
Add the correct display in Chrome and Safari.
*/
summary {
display: list-item;
}
/*
Removes the default spacing and border for appropriate elements.
*/
blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
margin: 0;
}
fieldset {
margin: 0;
padding: 0;
}
legend {
padding: 0;
}
ol,
ul,
menu {
list-style: none;
margin: 0;
padding: 0;
}
/*
Reset default styling for dialogs.
*/
dialog {
padding: 0;
}
/*
Prevent resizing textareas horizontally by default.
*/
textarea {
resize: vertical;
}
/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/
input::-moz-placeholder, textarea::-moz-placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
input::placeholder,
textarea::placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
/*
Set the default cursor for buttons.
*/
button,
[role="button"] {
cursor: pointer;
}
/*
Make sure disabled buttons don't get the pointer cursor.
*/
:disabled {
cursor: default;
}
/*
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
This can trigger a poorly considered lint error in some tools but is included by design.
*/
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
display: block;
/* 1 */
vertical-align: middle;
/* 2 */
}
/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img,
video {
max-width: 100%;
height: auto;
}
/* Make elements with the HTML hidden attribute stay hidden by default */
[hidden] {
display: none;
}
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
.container {
width: 100%;
}
@media (min-width: 640px) {
.container {
max-width: 640px;
}
}
@media (min-width: 768px) {
.container {
max-width: 768px;
}
}
@media (min-width: 1024px) {
.container {
max-width: 1024px;
}
}
@media (min-width: 1280px) {
.container {
max-width: 1280px;
}
}
@media (min-width: 1536px) {
.container {
max-width: 1536px;
}
}
.relative {
position: relative;
}
.-mx-3 {
margin-left: -0.75rem;
margin-right: -0.75rem;
}
.my-2 {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
.my-3 {
margin-top: 0.75rem;
margin-bottom: 0.75rem;
}
.my-4 {
margin-top: 1rem;
margin-bottom: 1rem;
}
.mb-0 {
margin-bottom: 0px;
}
.mb-1 {
margin-bottom: 0.25rem;
}
.mb-2 {
margin-bottom: 0.5rem;
}
.mb-3 {
margin-bottom: 0.75rem;
}
.mt-4 {
margin-top: 1rem;
}
.flex {
display: flex;
}
.contents {
display: contents;
}
.hidden {
display: none;
}
.w-full {
width: 100%;
}
.max-w-full {
max-width: 100%;
}
.cursor-pointer {
cursor: pointer;
}
.gap-2 {
gap: 0.5rem;
}
.overflow-hidden {
overflow: hidden;
}
.break-words {
overflow-wrap: break-word;
}
.rounded-lg {
border-radius: 0.5rem;
}
.border {
border-width: 1px;
}
.border-0 {
border-width: 0px;
}
.border-b {
border-bottom-width: 1px;
}
.border-solid {
border-style: solid;
}
.border-red-200 {
--tw-border-opacity: 1;
border-color: rgb(254 202 202 / var(--tw-border-opacity));
}
.border-zinc-200 {
--tw-border-opacity: 1;
border-color: rgb(228 228 231 / var(--tw-border-opacity));
}
.bg-red-100 {
--tw-bg-opacity: 1;
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
}
.p-3 {
padding: 0.75rem;
}
.px-12 {
padding-left: 3rem;
padding-right: 3rem;
}
.px-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.px-5 {
padding-left: 1.25rem;
padding-right: 1.25rem;
}
.py-2 {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.py-2\.5 {
padding-top: 0.625rem;
padding-bottom: 0.625rem;
}
.font-sans {
font-family: sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
}
.text-3xl {
font-size: 1.875rem;
line-height: 2.25rem;
}
.text-4xl {
font-size: 2.25rem;
line-height: 2.5rem;
}
.text-sm {
font-size: 0.875rem;
line-height: 1.25rem;
}
.font-semibold {
font-weight: 600;
}
.leading-8 {
line-height: 2rem;
}
.text-\[\#333\] {
--tw-text-opacity: 1;
color: rgb(51 51 51 / var(--tw-text-opacity));
}
.text-red-700 {
--tw-text-opacity: 1;
color: rgb(185 28 28 / var(--tw-text-opacity));
}
.text-sky-600 {
--tw-text-opacity: 1;
color: rgb(2 132 199 / var(--tw-text-opacity));
}
.underline {
text-decoration-line: underline;
}
input[type="number"] {
display: inline-block;
width: 70px;
}
.active-tab::after {
position: absolute;
width: 100%;
border-radius: 0.375rem;
--tw-bg-opacity: 1;
background-color: rgb(234 88 12 / var(--tw-bg-opacity));
/* background: #f78166; */
bottom: calc(50% - 22px);
content: "";
height: 2px;
right: 50%;
transform: translate(50%, -50%);
z-index: 1;
}
.form-control {
display: block;
border-radius: 0.375rem;
border-width: 1px;
border-style: solid;
--tw-border-opacity: 1;
border-color: rgb(212 212 216 / var(--tw-border-opacity));
--tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
padding-left: 0.75rem;
padding-right: 0.75rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
font-size: 1rem;
line-height: 1.5rem;
--tw-text-opacity: 1;
color: rgb(17 24 39 / var(--tw-text-opacity));
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}
.form-control::-moz-placeholder {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
}
.form-control::placeholder {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
}
.form-control:focus {
--tw-border-opacity: 1;
border-color: rgb(165 180 252 / var(--tw-border-opacity));
outline: 2px solid transparent;
outline-offset: 2px;
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
--tw-ring-color: rgb(199 210 254 / var(--tw-ring-opacity));
--tw-ring-opacity: 0.5;
}
textarea.form-control {
width: 100%;
resize: vertical;
}
.odd\:bg-\[\#f4f4f3\]:nth-child(odd) {
--tw-bg-opacity: 1;
background-color: rgb(244 244 243 / var(--tw-bg-opacity));
}
.even\:bg-\[\#e9e8e6\]:nth-child(even) {
--tw-bg-opacity: 1;
background-color: rgb(233 232 230 / var(--tw-bg-opacity));
}
.hover\:bg-zinc-100:hover {
--tw-bg-opacity: 1;
background-color: rgb(244 244 245 / var(--tw-bg-opacity));
}
.hover\:text-sky-800:hover {
--tw-text-opacity: 1;
color: rgb(7 89 133 / var(--tw-text-opacity));
}

26
src/css/app_src.css Normal file
View file

@ -0,0 +1,26 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
input[type="number"] {
display: inline-block;
width: 70px;
}
.active-tab::after {
@apply absolute w-full rounded-md bg-orange-600;
/* background: #f78166; */
bottom: calc(50% - 22px);
content: "";
height: 2px;
right: 50%;
transform: translate(50%, -50%);
z-index: 1;
}
.form-control {
@apply block rounded-md border border-solid border-zinc-300 bg-white px-3 py-2 text-base text-gray-900 transition-colors placeholder:text-gray-400 focus:border-indigo-300 focus:outline-none focus:ring focus:ring-indigo-200 focus:ring-opacity-50;
}
textarea.form-control {
@apply w-full resize-y;
}

6760
src/css/bootstrap.css vendored

File diff suppressed because it is too large Load diff

View file

@ -3,68 +3,64 @@
<head>
<meta charset="utf-8" />
<title>Shamir Secret Sharing Scheme</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/app.css">
<meta content="Shamir Secret Sharing Scheme tool" name="description"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="Ian Coleman" name="author" />
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1>Shamir Secret Sharing Scheme</h1>
<p>Split your secret into parts which can be combined back into the original secret using some or all of the parts.</p>
<body class="font-sans text-[#333]">
<div class="container px-12 my-4">
<div class="-mx-3 flex mb-3">
<div class="px-5">
<h1 class="text-4xl mb-3">Shamir Secret Sharing Scheme</h1>
<p class="mb-0">Split your secret into parts which can be combined back into the original secret using some or all of the parts.</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<h2>Split</h2>
<div>
Require
<input class="required form-control" type="number" value="3" min="2" max="255">
parts from
<input class="total form-control" type="number" value="5" min="2" max="255">
to reconstruct the following secret
</div>
<textarea class="secret form-control" rows=10 placeholder="Enter your secret here"></textarea>
<h2>Usage</h2>
<p>Double click each part below to select the content for that part. Copy and paste the content for each part into <span class="distributesize">5</span> individual files on your computer.</p>
<p>Distribute one file to each person in your group.</p>
<p>If <span class="recreatesize">3</span> of those people can combine the contents of their file using this page, they can view the secret.</p>
<p>Remember to delete the parts from your computer once you're finished. If you use a rubbish bin for deleted files, also remove them from the rubbish bin.</p>
<p class="error text-danger"></p>
<h2>Parts</h2>
<ol class="generated">
<li>Enter your secret above.</li>
</ol>
</div>
<div class="col-sm-6">
<h2>Combine</h2>
<p class="form-control-static">
Enter the secrets, one per line
</p>
<textarea class="parts form-control" rows=10></textarea>
<h2>Result</h2>
<pre class="combined">Enter your parts above.</pre>
<p id="error-message" class="text-red-700 my-3 w-full p-3 bg-red-100 rounded-lg hidden border-red-200 border"></p>
<div class="w-full flex gap-2 border-b border-zinc-200 border-solid border-0">
<div id="split-secret-tab" role="tab" class="px-2 leading-8 mb-1 text-sm font-semibold cursor-pointer hover:bg-zinc-100 rounded-lg relative active-tab">Split Secret</div>
<div id="combine-secret-tab" role="tab" class="px-2 leading-8 mb-1 text-sm cursor-pointer hover:bg-zinc-100 rounded-lg relative">Combine Secret</div>
</div>
<div id="split-secret" class="w-full my-4">
<!-- <h2>Split</h2> -->
<div class="mb-2">
Require
<input id="required-parts" class="form-control" type="number" value="3" min="2" max="255">
parts from
<input id="total-parts" class="form-control" type="number" value="5" min="2" max="255">
to reconstruct the following secret:
</div>
<textarea id="secret" class="form-control mb-3" rows=10 placeholder="Enter your secret here"></textarea>
<h2 class="text-3xl mb-3">Usage</h2>
<p class="mb-1">Double click each part below to select the content for that part. Copy and paste the content for each part into <span id="distributesize">5</span> individual files on your computer.</p>
<p class="mb-1">Distribute one file to each person in your group.</p>
<p class="mb-1">If <span id="recreatesize">3</span> of those people can combine the contents of their file using this page, they can view the secret.</p>
<p class="mb-3">Remember to delete the parts from your computer once you're finished. If you use a rubbish bin for deleted files, also remove them from the rubbish bin.</p>
<h2 class="text-3xl my-3">Parts</h2>
<ol id="generated" class="max-w-full break-words rounded-lg overflow-hidden">
<li>Enter your secret above.</li>
</ol>
</div>
<div id="combine-secret" class="hidden w-full my-4">
<!-- <h2>Combine</h2> -->
<p class="my-2 mb-2">
Enter the secrets, one per line
</p>
<textarea id="parts" class="form-control mb-3" rows=10></textarea>
<h2 class="text-3xl mb-3">Result</h2>
<p id="combined">Enter your parts above.</p>
</div>
<hr>
<div class="row">
<div class="col-sm-12">
<div class="sources">
<h2>Sources</h2>
<p><a href="https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing">Wikipedia entry</a> for shamir secret sharing scheme.</p>
<p>This project is 100% open-source code.</p>
<p><a href="https://github.com/iancoleman/shamir">Project source code</a></p>
<p><a href="https://github.com/grempe/secrets.js">SSSS javascript library by amper5and and Glenn Rempe</a></p>
<p><a href="https://getbootstrap.com/">Bootstrap stylesheet</a></p>
<h2>Offline Usage</h2>
<p>This tool has been designed to be used offline.</p>
<p>In your browser, select file save-as, and save this page as a file.</p>
<p>Double-click that file to open it in a browser on any offline computer.</p>
</div>
</div>
<div class="mt-4">
<h2 class="text-3xl mb-2">Sources</h2>
<p class="mb-1"><a href="https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing" class="text-sky-600 underline hover:text-sky-800">Wikipedia entry</a> for shamir secret sharing scheme.</p>
<p class="mb-1">This project is 100% open-source. <a href="https://github.com/iancoleman/shamir" class="text-sky-600 underline hover:text-sky-800">View the project source code on GitHub</a></p>
<p class="mb-1"><a href="https://github.com/grempe/secrets.js" class="text-sky-600 underline hover:text-sky-800">Built with the SSSS javascript library by amper5and and Glenn Rempe</a></p>
<p><a href="https://tailwindcss.com/" class="text-sky-600 underline hover:text-sky-800">Styled with Tailwind</a></p>
<h2 class="text-3xl mb-2 mt-4">Offline Usage</h2>
<p class="mb-1">This tool has been designed to be used offline.</p>
<p class="mb-1">In your browser, select file save-as, and save this page as a file.</p>
<p>Double-click that file to open it in a browser on any offline computer.</p>
</div>
</div>
<script src="js/secrets.js"></script>

View file

@ -2,15 +2,19 @@
(function() {
var DOM = {};
DOM.required = $(".required");
DOM.total = $(".total");
DOM.secret = $(".secret");
DOM.distributesize = $(".distributesize");
DOM.recreatesize = $(".recreatesize");
DOM.error = $(".error");
DOM.generated = $(".generated");
DOM.parts = $(".parts");
DOM.combined = $(".combined");
DOM.required = $("#required-parts");
DOM.total = $("#total-parts");
DOM.secret = $("#secret");
DOM.distributesize = $("#distributesize");
DOM.recreatesize = $("#recreatesize");
DOM.error = $("#error-message");
DOM.generated = $("#generated");
DOM.parts = $("#parts");
DOM.combined = $("#combined");
DOM.splitSecret = $("#split-secret")
DOM.splitSecretTab = $("#split-secret-tab")
DOM.combineSecret = $("#combine-secret")
DOM.combineSecretTab = $("#combine-secret-tab")
function init() {
// Events
@ -18,6 +22,35 @@
DOM.total.addEventListener("input", generateParts);
DOM.secret.addEventListener("input", generateParts);
DOM.parts.addEventListener("input", combineParts);
DOM.splitSecretTab.addEventListener("click", () => {
clearError()
switchTab(true)
})
DOM.combineSecretTab.addEventListener("click", () => {
clearError()
switchTab(false)
})
}
function switchTab(split) {
DOM.splitSecretTab.classList.toggle("font-semibold", split)
DOM.splitSecretTab.classList.toggle("active-tab", split)
DOM.combineSecretTab.classList.toggle("font-semibold", !split)
DOM.combineSecretTab.classList.toggle("active-tab", !split)
DOM.splitSecret.classList.toggle("hidden", !split)
DOM.combineSecret.classList.toggle("hidden", split)
}
function setError(message) {
DOM.error.textContent = "Error: " + message;
DOM.error.classList.toggle("hidden", false)
}
function clearError() {
DOM.error.textContent = "";
DOM.error.classList.toggle("hidden", true)
}
function generateParts() {
@ -30,39 +63,39 @@
var required = parseFloat(DOM.required.value);
// validate the input
if (total < 2) {
DOM.error.textContent = "Total must be at least 1";
setError("Total must be at least 2")
return;
}
else if (total > 255) {
DOM.error.textContent = "Total must be at most 255";
setError("Total must be at most 255")
return;
}
else if (required < 2) {
DOM.error.textContent = "Required must be at least 1";
setError("Required must be at least 2")
return;
}
else if (required > 255) {
DOM.error.textContent = "Required must be at most 255";
setError("Required must be at most 255")
return;
}
else if (isNaN(total)) {
DOM.error.textContent = "Invalid value for total";
setError("Invalid value for total")
return;
}
else if (isNaN(required)) {
DOM.error.textContent = "Invalid value for required";
setError("Invalid value for required")
return;
}
else if (required > total) {
DOM.error.textContent = "Required must be less than total";
setError("Required must be less than total")
return;
}
else if (secret.length == 0) {
DOM.error.textContent = "Secret is blank";
setError("Secret is blank")
return;
}
else {
DOM.error.textContent = "";
clearError()
}
// Generate the parts to share
var minPad = 1024; // see https://github.com/amper5and/secrets.js#note-on-security
@ -71,7 +104,7 @@
for (var i=0; i<shares.length; i++) {
var share = shares[i];
var li = document.createElement("li");
li.classList.add("part");
li.classList.add("px-2", "py-2.5", "odd:bg-[#f4f4f3]", "even:bg-[#e9e8e6]");
li.textContent = share;
DOM.generated.appendChild(li);
}

18
tailwind.config.js Normal file
View file

@ -0,0 +1,18 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {
fontFamily: {
sans: [
"sans-serif",
"Apple Color Emoji",
"Segoe UI Emoji",
"Segoe UI Symbol",
"Noto Color Emoji",
],
},
},
},
plugins: [],
};