mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-04 10:24:46 +03:00
feat(new tool): OVH X-VR-SPAMCAUSE Decoder
This commit is contained in:
1 parent
35600c2990
commit
3a272f60c9
7 files changed
+1349
-1187
No files matched your search
@@ -25,6 +25,7 @@ import { tool as angleConverter } from './angle-converter';
|
||||
import { tool as floatingPointNumberConverter } from './floating-point-number-converter';
|
||||
import { tool as snowflakeIdExtractor } from './snowflake-id-extractor';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
import { tool as xVrSpamcauseDecoder } from './x-vr-spamcause-decoder';
|
||||
import { tool as bounceParser } from './bounce-parser';
|
||||
import { tool as codeHighlighter } from './code-highlighter';
|
||||
import { tool as colorWheel } from './color-wheel';
|
||||
@@ -488,6 +489,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
portNumbers,
|
||||
raidCalculator,
|
||||
sipAuth,
|
||||
xVrSpamcauseDecoder,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { RecordMail } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'X-VR-SpamCause Decoder',
|
||||
path: '/x-vr-spamcause-decoder',
|
||||
description: 'Decode X-VR-SPAMCAUSE header in OVH mails',
|
||||
keywords: ['ovh', 'vade', 'retro', 'vr', 'spam', 'spamcause', 'decoder'],
|
||||
component: () => import('./x-vr-spamcause-decoder.vue'),
|
||||
icon: RecordMail,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { spamCauseDecode } from './x-vr-spamcause-decoder.service';
|
||||
|
||||
describe('x-vr-spamcause-decoder', () => {
|
||||
it('should decode X-VR-SPAMCAUSE', () => {
|
||||
expect(spamCauseDecode('gggruggvucftvghtrhhoucdtuddrfeelgedrvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucgohfhorhgsihguuggvnhfjughrucdlhedttddm')).toBe(
|
||||
'Vade Retro 01.394.21 AS+AV+AP+RT Profile: OVH; Bailout: 300; ^ForbiddenHdr (500)',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
function unrot(a: string, b: string, pos: number) {
|
||||
if (b === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (pos % 2 === 0) {
|
||||
const c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
|
||||
const offset = ('g'.charCodeAt(0) - a.charCodeAt(0)) * 16;
|
||||
return String.fromCharCode((a.charCodeAt(0) + b.charCodeAt(0)) - 'x'.charCodeAt(0) - offset);
|
||||
}
|
||||
|
||||
export function spamCauseDecode(text: string) {
|
||||
let result = '';
|
||||
|
||||
for (let n = 0; n < text.length; n += 2) {
|
||||
result += unrot(text[n], text[n + 1], Math.floor(n / 2));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { spamCauseDecode } from './x-vr-spamcause-decoder.service';
|
||||
|
||||
const encodedXVRSpamCause = ref('');
|
||||
const decoded = computed(() => spamCauseDecode(encodedXVRSpamCause.value));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="encodedXVRSpamCause"
|
||||
label="Encoded X-VR-SPAMCAUSE:"
|
||||
multiline
|
||||
rows="1"
|
||||
autosize
|
||||
placeholder="Your X-VR-SPAMCAUSE header value..."
|
||||
mb-6
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<textarea-copyable readonly label="Decoded" :value="decoded" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user