mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-23 08:16:16 -04:00
Merge branch 'CorentinTh:main' into main
This commit is contained in:
commit
378b3d8735
6 changed files with 13 additions and 10 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
- run: corepack enable
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
|
|
2
.github/workflows/e2e-tests.yml
vendored
2
.github/workflows/e2e-tests.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
|||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get Playwright version
|
||||
|
|
|
@ -9,7 +9,7 @@ const useWebServer = process.env.NO_WEB_SERVER !== 'true';
|
|||
*/
|
||||
export default defineConfig({
|
||||
testDir: './src',
|
||||
testMatch: /.*\.e2e\.(spec\.)?ts/,
|
||||
testMatch: /\.e2e\.(spec\.)?ts$/,
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
|
@ -57,7 +57,7 @@ export default defineConfig({
|
|||
&& {
|
||||
webServer: {
|
||||
command: 'npm run preview',
|
||||
url: 'http://127.0.0.1:5050',
|
||||
url: 'http://localhost:5050',
|
||||
reuseExistingServer: !isCI,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ const compareMatch = computed(() => compareSync(compareString.value, compareHash
|
|||
mb-2
|
||||
/>
|
||||
<n-form-item label="Salt count: " label-placement="left" label-width="120">
|
||||
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="10" :min="0" w-full />
|
||||
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
|
||||
</n-form-item>
|
||||
|
||||
<c-input-text :value="hashed" readonly text-center />
|
||||
|
|
|
@ -11,6 +11,9 @@ describe('integer-base-converter', () => {
|
|||
expect(convertBase({ value: '10100101', fromBase: 2, toBase: 16 })).toEqual('a5');
|
||||
expect(convertBase({ value: '192654', fromBase: 10, toBase: 8 })).toEqual('570216');
|
||||
expect(convertBase({ value: 'zz', fromBase: 64, toBase: 10 })).toEqual('2275');
|
||||
expect(convertBase({ value: '42540766411283223938465490632011909384', fromBase: 10, toBase: 10 })).toEqual('42540766411283223938465490632011909384');
|
||||
expect(convertBase({ value: '42540766411283223938465490632011909384', fromBase: 10, toBase: 16 })).toEqual('20010db8000085a300000000ac1f8908');
|
||||
expect(convertBase({ value: '20010db8000085a300000000ac1f8908', fromBase: 16, toBase: 10 })).toEqual('42540766411283223938465490632011909384');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,16 +5,16 @@ export function convertBase({ value, fromBase, toBase }: { value: string; fromBa
|
|||
let decValue = value
|
||||
.split('')
|
||||
.reverse()
|
||||
.reduce((carry: number, digit: string, index: number) => {
|
||||
.reduce((carry: bigint, digit: string, index: number) => {
|
||||
if (!fromRange.includes(digit)) {
|
||||
throw new Error(`Invalid digit "${digit}" for base ${fromBase}.`);
|
||||
}
|
||||
return (carry += fromRange.indexOf(digit) * fromBase ** index);
|
||||
}, 0);
|
||||
return (carry += BigInt(fromRange.indexOf(digit)) * BigInt(fromBase) ** BigInt(index));
|
||||
}, 0n);
|
||||
let newValue = '';
|
||||
while (decValue > 0) {
|
||||
newValue = toRange[decValue % toBase] + newValue;
|
||||
decValue = (decValue - (decValue % toBase)) / toBase;
|
||||
newValue = toRange[Number(decValue % BigInt(toBase))] + newValue;
|
||||
decValue = (decValue - (decValue % BigInt(toBase))) / BigInt(toBase);
|
||||
}
|
||||
return newValue || '0';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue