screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h1>Vue js Generate Hash Password</h1> <form @submit.prevent="generateHashPass"> <label for="password">Password:</label> <input type="password" id="password" v-model="password" /> <button type="submit">Generate Hash Password</button> <small v-if="hashPassword">Hash Password: {{hashPassword}}</small> </form> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { password: "123456789", hashPassword: '' }; }, methods: { async generateHashPass() { const password = this.password; const encoder = new TextEncoder(); const data = encoder.encode(password); const hash = await crypto.subtle.digest("SHA-256", data); const hashArray = Array.from(new Uint8Array(hash)); const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join(""); this.hashPassword = hashHex }, }, }) </script> <style scoped> /* Set global font properties */ html, body { font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; } /* Set app container styles */ #app { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background-color: #f2f2f2; } /* Set heading styles */ h1 { font-size: 2.5rem; margin-top: 0; margin-bottom: 1rem; color: #333; } /* Set form container styles */ form { display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: #fff; padding: 2rem; border-radius: 0.5rem; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); width: 100%; max-width: 500px; } /* Set label styles */ label { font-size: 1.2rem; margin-bottom: 0.5rem; color: #333; } /* Set input styles */ input[type="password"] { padding: 0.5rem; border-radius: 0.25rem; border: 1px solid #ccc; margin-bottom: 1rem; width: 100%; box-sizing: border-box; } /* Set button styles */ button[type="submit"] { padding: 0.5rem 1rem; background-color: #008CBA; color: #fff; border: none; border-radius: 0.25rem; cursor: pointer; transition: all 0.3s ease-in-out; } button[type="submit"]:hover { background-color: #006c87; } /* Set hash password text styles */ small { font-size: 1rem; margin-top: 1rem; color: #666; } </style> </body> </html>