Rectangle 27 0

md5 and passwords in the same sentence gives me chills.. md5 is a type of one-way hash function, which mean there should be no way to "decrypt" once hashed. It is not an encryption function. However, with rainbow table (and possibly other ways), you can recover some common strings from a md5 hash, which makes the idea of using md5 to encrypt password even worse.

But anyway, here is the answer:

No, the Python script's answer is the correct one. If you use echo -n "robots" | md5sum you will see they are the same: 27f5e15b6af3223f1176293cd015771d

The reason is echo will append a newline character at the end of the string it's echoing (surprise!), adding -n will not print the newline char and hence give you the right result.

Alternatively, you can simply use md5sum -s "robots" or md5 -s "robots" to generate the hash without using echo.

Reference for echo:

The echo utility writes any specified operands, separated by single blank (' ') characters and followed by a newline (\n) character, to the standard output.

python - Will a website be able to decrypt a hashed password regardles...

python hash md5
Rectangle 27 0

Wind Chill Table [C++]

#include <iostream> 
#include <iomanip> 
#include <cmath> 
using namespace std; 

int windChill(int airTemp, int windSpeed); 

int main() 
{ 
         
        cout << setw(5) << "|Wind Chill Table|" << endl;
        cout << setw(5) << "|Speed|" "|Temperature|" << endl; 
        cout << setw(5) << "|MPH|"; 
        for (int x = 45; x > -15; x -= 5) 
                cout << setw(5) << x; 
        cout << endl; 
        cout << "---------------------------------------------------------------------";
        cout << endl;

        
        for (int wind = 5; wind <= 50; wind += 5) 
        { 
                cout << setw(5) << wind << " |"; 
                for (int temp = 45; temp >= -10; temp -= 5) 
                { 
                        cout << setw(5) << windChill(temp, wind); 
                } 
                cout << endl; 
        } 
        cout << "----------------------------------------------------------------------";
        return 0; 
} 

int windChill(int airTemp, int windSpeed) 
{ 
        return round (35.74 + (0.6215 * airTemp) - (35.75 * pow(windSpeed, 0.16)) + (0.4275 * airTemp * pow(windSpeed, 0.16)));
            
}
C++
Rectangle 27 0

You need to loop through all values of both temp and windspeed, recalculating wind chill each time. A nice way to do this may be to redefine windChill as a function. To get the table to print with the correct spacing you can use string formatting.

def main():    
    def wind_chill(temp, wind_speed):
        return 35.74 + (0.6215 * temp) - 35.75 * (wind_speed ** 0.16) \
            + 0.4275 * temp * (wind_speed ** 0.16)

    heading = '  '
    for temp in range(-20, 70, 10):
        heading += "{:>7d}".format(temp)
    print heading + "\n   " + "-" * 62    
    for wind_speed in range (0, 35, 5):
        output_line = "{:>2d}".format(wind_speed)
        for temp in range(-20, 70, 10):
            output_line += "{:>7.1f}".format(wind_chill(temp, wind_speed))
        print output_line

main()

Alternatively set all of the data in a 2d array (list of lists) first and then print it out using a single long format string. (This uses sum to flatten the list of lists into a single long sequence.)

def main():    
    temps = range(-20, 70, 10)
    winds = range(0, 35, 5)
    chill = [[w] + [35.74 + .6215 * t - 35.75 * w**.16 + .4275 * t * w**.16 
                   for t in temps] for w in winds]
    rows = len(winds)
    cols = len(temps)
    print ('  ' + '{:7d}' * cols + '\n  ' + '-' * cols * 7
           + ('\n{:2d}' + '{:7.1f}' * cols) * rows).format(*sum(chill, temps))

python - windchill table using nested loop - Stack Overflow

python python-2.7 nested-loops