Files
it-tools-pro/src/tools/ipv6-ula-generator/ipv6-ula-generator.vue
T
personal82555 01ff133ac9 IT-TOOLS-PRO v1 - 定制版开发者工具站
12个原创工具(批量条码/二维码识别/在线翻译/OCR/面单设计/AI修图/网站收藏/PDF工具/图片工具/文档转换等)
+ 卡密授权系统(CardAuth对接,30分钟试用,换卡/撤销)
+ 体验优化(中文默认/收藏/最近使用/菜单展开/宽屏/品牌页脚)
2026-10-11 23:58:39 +08:00

66 lines
1.6 KiB
Vue

<script setup lang="ts">
import { SHA1 } from 'crypto-js';
import InputCopyable from '@/components/InputCopyable.vue';
import { macAddressValidation } from '@/utils/macAddress';
const macAddress = ref('20:37:06:12:34:56');
const calculatedSections = computed(() => {
const timestamp = new Date().getTime();
const hex40bit = SHA1(timestamp + macAddress.value)
.toString()
.substring(30);
const ula = `fd${hex40bit.substring(0, 2)}:${hex40bit.substring(2, 6)}:${hex40bit.substring(6)}`;
return [
{
label: 'IPv6 ULA:',
value: `${ula}::/48`,
},
{
label: 'First routable block:',
value: `${ula}:0::/64`,
},
{
label: 'Last routable block:',
value: `${ula}:ffff::/64`,
},
];
});
const addressValidation = macAddressValidation(macAddress);
</script>
<template>
<div>
<n-alert title="Info" type="info">
This tool uses the first method suggested by IETF using the current timestamp plus the mac address, sha1 hashed,
and the lower 40 bits to generate your random ULA.
</n-alert>
<c-input-text
v-model:value="macAddress"
placeholder="Type a MAC address"
clearable
label="MAC address:"
raw-text
my-8
:validation="addressValidation"
/>
<div v-if="addressValidation.isValid">
<InputCopyable
v-for="{ label, value } in calculatedSections"
:key="label"
:value="value"
:label="label"
label-width="160px"
label-align="right"
label-position="left"
readonly
mb-2
/>
</div>
</div>
</template>