WeBWorK Main Forum

Trying to create ClassList file for students - Passwords Not Crypting

Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -
Number of replies: 13

Good Morning - 

I am trying to create a student file to upload into our WeBWorK 2.17. I ran the crypt_passwords_in_classlist.pl script from the wiki/GitHub on my lst file. When I opened the crypted_ prefixed file in a text editor, I noticed that the passwords that I specified remained the same in plain text.  

I am not sure what is going on. (I am new to WeBWork) and how to fix it. 

We have Strawberry Perl running on our desktops.

This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread
Copyright 1987-2021, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. 
Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl".  If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.


Here is what I ran and the output that I received. I am attaching the Demo_Class_List2.lst file and the resulting crypted_Demo_Class_List2.lst file as a ZIP file 

C:\Users\ghotko\Desktop>perl crypt_passwords_in_classlist.pl Demo_Class_List2.lst

Output is in the file crypted_Demo_Class_List2.lst


In reply to Gary Hotko

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Glenn Rice -
Your classlist file has the wrong number of columns. The fields that the file should have are

student_id, last_name, first_name, status, comment, section, recitation, email_address, user_id, password, permission

You are missing one of the fields between status and email_address. Just add another comma in there.
In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -
Hi Glenn - Thank you

However, when I did the update, I am now not seeing anything in the password field when I open the Crypted... file in notepad++ 

I have attached the new demo lst and crypted demo lst files. 


In reply to Gary Hotko

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Glenn Rice -
That is odd. When I run the script on the classlist file that you just attached I get the file that I attached.  Do you get any errors or warnings when you run the script?
In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Glenn Rice -
Ahh, so this seems to be another issue with CRLF line endings. Stupid, stupid thing done by Microsoft, and has never been anything but trouble. Your script is in dos format with CRLF line endings. Convert it to unix format without those, and the script should work. Your classlist file is also in dos format, but that doesn't seem to cause a problem.
In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -
In Notepad++, it is saved in PERL format. I do not see an option to save it otherwise. 
I tried resaving them again (attached them) if there are any tools or tricks that you can suggest, would be appreciated. 


In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -
This is strange.

Here is the output from the command line:

C:\Users\ghotko\Desktop>dir *.lst
 Volume in drive C is Windows
 Volume Serial Number is 2E1C-C044

 Directory of C:\Users\ghotko\Desktop

03/06/2023  07:09 AM             5,985 crypted_Demo_Class_List.lst
03/06/2023  07:18 AM             5,823 crypted_Demo_Class_List2.lst
03/06/2023  10:29 AM            14,163 crypted_Demo_Class_List_3 (1).lst
03/06/2023  09:47 AM             5,577 crypted_Demo_Class_List_3.lst
03/06/2023  07:04 AM             6,228 Demo_Class_List.lst
03/06/2023  07:18 AM             6,066 Demo_Class_List2.lst
03/06/2023  09:45 AM             6,306 Demo_Class_List_3.lst
03/06/2023  09:45 AM             6,306 Demo_Class_List_4.lst
               8 File(s)         56,454 bytes
               0 Dir(s)  60,798,500,864 bytes free

C:\Users\ghotko\Desktop>dir *.pl
 Volume in drive C is Windows
 Volume Serial Number is 2E1C-C044

 Directory of C:\Users\ghotko\Desktop

02/23/2023  11:26 AM                34 amit.pl
03/06/2023  07:06 AM             1,519 crypt_passwords_in_classlist.pl
               2 File(s)          1,553 bytes
               0 Dir(s)  60,798,111,744 bytes free

C:\Users\ghotko\Desktop>PERL crypt_passwords_in_classlist.pl Demo_Class_List_4.lst
Output is in the file crypted_Demo_Class_List_4.lst

Would it be possible for you to share your version of the crypting script? I wonder if there is an issue with my copy.

In reply to Gary Hotko

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Glenn Rice -

My copy of the script is attached.  I noticed that the file in the last zip you attached still has CRLF line endings.  When I try to execute it I get errors.  Notepad++ usually does a decent job with removing line endings, so you might check your settings in that application.

In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -

Good Morning - 

I tried again today using the version that you attached. I am still getting the same non-crypted output. 

I went in Notepad++ and changed from CRLF to just LF - no change. The output file that I received back from the script was in CRLF endings. 

C:\Users\ghotko>cd Desktop
C:\Users\ghotko\Desktop>perl crypt_passwords_in_classlist.pl Demo_Class_List_9.lst
Output is in the file crypted_Demo_Class_List_9.lst
C:\Users\ghotko\Desktop>perl crypt_passwords_in_classlist3.pl Demo_Class_List_9.lst
Output is in the file crypted_Demo_Class_List_9.lst
C:\Users\ghotko\Desktop>

I am a complete novice when it comes to PERL. Is there a way to test if crypt is actually working?

Thanks. 

In reply to Gary Hotko

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Glenn Rice -

I am not sure what is going on for you here.  The fact that you are not getting any errors when you run the script indicates that the CRLF endings is probably not your problem.  Most likely your version of Perl is adapted to handle that on windows.

Here is a test that might give some information.  I have attached a script.  Run the script.  It will output a hash for the password "password", and then ask you to enter "password".  If it does not output an encrypted hash for your, then "crypt" is definitely not working.  If it does not say "Correct!" after you enter "password" then it is also not working.  The script just encryptes "password" in the same way that webwork2 creates password hashes, and then verifies the entered "password" also in the same way that webwork2 does.


In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -
Glenn  - Thank you for all of your help and support on this. 

When I first run your script I get:
C:\Users\ghotko\Desktop>perl crypt-password-ww2.pl
Use of uninitialized value $hash in concatenation (.) or string at crypt-password-ww2.pl line 16.

When I follow your instructions -- I receive: 

C:\Users\ghotko\Desktop>perl crypt-password-ww2.pl
Use of uninitialized value $hash in concatenation (.) or string at crypt-password-ww2.pl line 16.
Encrypted Password:
Enter password (yes, really enter "password"): password
Use of uninitialized value $hash in crypt at crypt-password-ww2.pl line 22, <STDIN> line 1.
Use of uninitialized value in string eq at crypt-password-ww2.pl line 22, <STDIN> line 1.
Use of uninitialized value $hash in string eq at crypt-password-ww2.pl line 22, <STDIN> line 1.
Correct!

C:\Users\ghotko\Desktop>
In reply to Gary Hotko

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Danny Glin -
I can confirm that with strawberry perl in Windows I am also seeing the crypt function return an empty string.

I came across this, which may explain why it's not working in Windows.

All of the easy solutions I can think of involve getting access to something linux-like to run perl, but they generally require having administrator access to the computer to install software.  These include using Windows Subsystem for Linux, creating a docker container to run perl, or installing Cygwin.  There are probably simpler things that I'm not thinking of as well.
In reply to Danny Glin

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Glenn Rice -

One possibility would be to write a python script that will do this.  I know that the passlib.hash.sha512_crypt method generates passwords that work with webwork2.  That is more likely to have cross platform support.

In reply to Glenn Rice

Re: Trying to create ClassList file for students - Passwords Not Crypting

by Gary Hotko -
I spoke to our IT admin for the WW server and they gave me ssh access to the server to run the crypt there.

Thank you all for your troubleshooting assistance.