{"id":2365,"date":"2025-09-25T06:58:49","date_gmt":"2025-09-25T06:58:49","guid":{"rendered":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/?page_id=2365"},"modified":"2025-09-25T07:06:37","modified_gmt":"2025-09-25T07:06:37","slug":"h12-password-hash","status":"publish","type":"page","link":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/h12-password-hash\/","title":{"rendered":"H12: Password Hash"},"content":{"rendered":"\n<ol class=\"wp-block-list\">\n<li>Ava enda koodiredaktor<\/li>\n\n\n\n<li>Tee uus fail nimega <code>generateHash.js<\/code><\/li>\n\n\n\n<li>Lisa sinna j\u00e4rgnev kood:<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e1e4e8;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2f363c;color:#d3d7dd\">JavaScript<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>const bcrypt = require('bcrypt');\nconst myPassword = 'Vladislav Kudriashev';\n\nconsole.time('Time to generate salt');\nconst salt = bcrypt.genSaltSync(10);\nconsole.log('This is your salt: ' + salt);\nconsole.timeEnd('Time to generate salt');\n\nconsole.time('Time to generate hash');\nconst hashedPassword = bcrypt.hashSync(myPassword, salt);\nconsole.log(myPassword +\n    ' is your password &amp; this is your password after hashing it: '\n    + hashedPassword);\nconsole.timeEnd('Time to generate hash');<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">const<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">bcrypt<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">require<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&#39;bcrypt&#39;<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">const<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">myPassword<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;Vladislav Kudriashev&#39;<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">console.<\/span><span style=\"color: #B392F0\">time<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&#39;Time to generate salt&#39;<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">const<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">salt<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> bcrypt.<\/span><span style=\"color: #B392F0\">genSaltSync<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">10<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">console.<\/span><span style=\"color: #B392F0\">log<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&#39;This is your salt: &#39;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> salt);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">console.<\/span><span style=\"color: #B392F0\">timeEnd<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&#39;Time to generate salt&#39;<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">console.<\/span><span style=\"color: #B392F0\">time<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&#39;Time to generate hash&#39;<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">const<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">hashedPassword<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> bcrypt.<\/span><span style=\"color: #B392F0\">hashSync<\/span><span style=\"color: #E1E4E8\">(myPassword, salt);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">console.<\/span><span style=\"color: #B392F0\">log<\/span><span style=\"color: #E1E4E8\">(myPassword <\/span><span style=\"color: #F97583\">+<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #9ECBFF\">&#39; is your password &amp; this is your password after hashing it: &#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> hashedPassword);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">console.<\/span><span style=\"color: #B392F0\">timeEnd<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&#39;Time to generate hash&#39;<\/span><span style=\"color: #E1E4E8\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<ol start=\"4\" id=\"yui_3_17_2_1_1758779186262_543\" class=\"wp-block-list\">\n<li>Paigaldada bcrypt k\u00e4suga <code>npm install bcrypt<\/code><\/li>\n\n\n\n<li><code>node .\\generateHash.js<\/code><\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e1e4e8;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:clamp(20px, 1.25rem, 30px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2f363c;color:#d3d7dd\">Astro<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>This is your salt: $2b$10$biyHElrgZfGzmGhiSgFM5O\nTime to generate salt: 3.887ms\nVladislav Kudriashev is your password &amp; this is your password after hashing it: $2b$10$biyHElrgZfGzmGhiSgFM5OQgneduErhVfMdZD4X.cwd..MuR4KxLW\nTime to generate hash: 56.779ms<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">This is your salt: $2b$10$biyHElrgZfGzmGhiSgFM5O<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Time to generate salt: 3.887ms<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Vladislav Kudriashev is your password &amp; this is your password after hashing it: $2b$10$biyHElrgZfGzmGhiSgFM5OQgneduErhVfMdZD4X.cwd..MuR4KxLW<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Time to generate hash: 56.779ms<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Kokkuv\u00f5tte<\/h2>\n\n\n\n<p>Parooli soolamine (Password salting) &#8211; lisab parooli ette v\u00f5i taha juhuslikke m\u00e4rke enne parooli r\u00e4si arvutamist, et muuta tegelik parool raskemini \u00e4ratuntavaks ja kaitsta seda lihtsate r\u00fcnnakute<\/p>\n\n\n\n<p>Parooli r\u00e4si (Password hashing) &#8211; on \u00fchesuunaline protsess, mis muudab parooli r\u00e4si kujul olevaks tekstiks, kasutades spetsiaalseid r\u00e4siarvutusalgoritme.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kokkuv\u00f5tte Parooli soolamine (Password salting) &#8211; lisab parooli ette v\u00f5i taha juhuslikke m\u00e4rke enne parooli r\u00e4si arvutamist, et muuta tegelik parool raskemini \u00e4ratuntavaks ja kaitsta seda lihtsate r\u00fcnnakute Parooli r\u00e4si (Password hashing) &#8211; on \u00fchesuunaline protsess, mis muudab parooli r\u00e4si kujul olevaks tekstiks, kasutades spetsiaalseid r\u00e4siarvutusalgoritme.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2365","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/pages\/2365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/comments?post=2365"}],"version-history":[{"count":8,"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/pages\/2365\/revisions"}],"predecessor-version":[{"id":2375,"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/pages\/2365\/revisions\/2375"}],"wp:attachment":[{"href":"https:\/\/vladislavkudriashev23.thkit.ee\/WP\/wp-json\/wp\/v2\/media?parent=2365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}