Event JSON
{
"id": "1caa3852d5ce595fd1dc440f06a0e66b1b76d72ecc47153592bca4bf48c3c9dc",
"pubkey": "a311301faa1b9a4e96960184ee442f70c6cbb738044ec963ad42ff264663f8f2",
"created_at": 1737581978,
"kind": 30023,
"tags": [
[
"client",
"Yakihonne",
"31990:20986fb83e775d96d188ca5c9df10ce6d613e0eb7e5768a0f0b12b37cdac21b3:1700732875747"
],
[
"published_at",
"1737575902"
],
[
"d",
"0_YoTxKzp1BPpdf8vSd_F"
],
[
"image",
"https://alashazam.wordpress.com/wp-content/uploads/2024/01/cperl-camel.jpeg"
],
[
"title",
"perl password (Windows version)"
],
[
"summary",
"Perl entering password (Windows version)\nwith encoding troubleshooting included "
],
[
"zap",
"a311301faa1b9a4e96960184ee442f70c6cbb738044ec963ad42ff264663f8f2",
"",
"100"
],
[
"t",
"perl"
],
[
"t",
"programming"
]
],
"content": "```perl\n#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse Term::ReadKey;\n\nSTDOUT-\u003eautoflush(1);\n\n# this version run on Windows and use a pwd.txt file created by\n# the perl program ; otherwise encoding issue may follow\n# following sub needs to be used first by uncommenting the main call\nsub write_password {\n print (\"Enter Password: \") ; \n my $password = \u003cSTDIN\u003e;\n my $file_path = 'pwd.txt';\n open(my $fh, '\u003e', $file_path) or die \"Cannot open file '$file_path' for writing: $!\";\n print $fh $password;\n close($fh);\n print (\"\\n\"); \n print \"Password written to '$file_path'\\n\";\n}\n\nsub printhex {\n my $str = shift ; \n foreach my $char (split //, $str) {\n printf \"%02x \", ord($char);\n }\n print \"\\n\";\n}\n\n# Function to read password from file\nsub read_password_from_file {\n #unecessary\n #binmode(STDIN, ':crlf'); \n my $file_path = shift;\n #unecessary\n #local $/ = \"\\r\\n\" ; # CR, use \"\\r\\n\" for CRLF or \"\\n\" for LF\n open(my $fh, '\u003c', $file_path) or die \"Cannot open file '$file_path' for reading: $!\";\n my $password = \u003c$fh\u003e;\n close($fh);\n #printhex ($password) ; \n chomp($password); \n print \"'$password'\\n\" ;\n #$password =~ s/\\r?\\n$//; # Remove newline character\n #$password = substr($password, 2) ; # BOM File starts with FF FE \n printhex($password ) ; # \"\\'$password\\'\\n\" ;\n #$password = \"abcde\" ; \n return $password;\n}\n\n# Main program\nsub main {\n #write_password(); # to uncomment for first use\n my $correct_password = read_password_from_file(\"pwd.txt\") ; \n print \"Enter password: \";\n ReadMode('noecho'); # Turn off echo\n my $entered_password = ReadLine(0);\n ReadMode('restore'); # Restore echo\n chomp($entered_password);\n print \"\\n\";\n\n # Compare entered password with the correct password\n if ($entered_password eq $correct_password) {\n print \"Access granted!\\n\";\n } else {\n print \"Access denied!\\n\";\n print \"'$entered_password' not eq '$correct_password' \\n\"; \n printhex ($entered_password); \n printhex ($correct_password) ; \n print \"The end! \\n\" ; \n }\n}\n\n# Call main function\nmain();\n\n```",
"sig": "ba22b6981c87e8560b3174f8b6fe0db715a2e5e004ccddc0bea5ce3e560bf7167f713e43fa83709c23b6e523a967fa5d832957dba6ae28dc7637ba537e57ebc8"
}