Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Briefly describe what the purpose of this script is. Also explain how the script

ID: 3670881 • Letter: B

Question

Briefly describe what the purpose of this script is. Also explain how the script carries out this purpose. You should describe the code in blocks. So you want to say things like the if statement that goes from line x to line y defines what the program will do when condition z is true. Then, explain how those lines carry that purpose out.

- auth_funcs.sql

create or replace function do_hash(_mystring text)

returns text as

$func$

begin

return encode(digest(_mystring,'sha512'),'hex');

end;

$func$

language 'plpgsql';

create or replace function make_salt(_mystring text)

returns text as

$func$

begin

return do_hash(now() || _mystring);

end;

$func$

language 'plpgsql';

create or replace function make_enc_pass(_mystring text)

returns text as

$func$

begin

return do_hash(_mystring || make_salt(_mystring));

end;

$func$

language 'plpgsql';

Explanation / Answer

Q1.
create or replace function do_hash(_mystring text)
returns text as
$func$
begin
return encode(digest(_mystring,'sha512'),'hex');
end;
$func$
language 'plpgsql';
  
  
This script is taking a text, and performing an encryption to that text. The algorithm being used is a SHA-512 authentication algo.
  
Q2. create or replace function make_salt(_mystring text)
returns text as
$func$
begin
return do_hash(now() || _mystring);
end;
$func$
language 'plpgsql';
  
This script is also taking a text and concatenates it with the current date and time, and performing an encryption to that text. The algorithm being used is a hash authentication which makes use of SHA-1 algo.
  
Q3.   create or replace function make_enc_pass(_mystring text)
returns text as
$func$
begin
return do_hash(_mystring || make_salt(_mystring));
end;
$func$
language 'plpgsql';
  
  
Here the script takes a text string. It calculates the hash using make_salt function of the text, and then concatenates the original text and new encoded text, and again applies the SHA-1 algorithm on it.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote