Hi. I have created a custom password field on empl...
# suitescript
n
Hi. I have created a custom password field on employee record. I have entered a password in it, saved the record. Using the search, I am able to get the encrypted value of this password. I have created a suitelet with username and password field. I am entering the same value of the password in this field, getting it in the POST request and encrypting it using:
Copy code
var hash = nsCrypto.createHash({
   algorithm: nsCrypto.HashAlg.SHA1
});
hash.update({  input: password, });
var hashedVal = hash.digest({ outputEncoding: nsEncode.Encoding.UTF_8});
But the hashedVal is different than the encrypted value return in the search result. Am I missing something?
@battk any help?
b
that doesnt sound like the correct way to use a password field, nor is it considered a modern way to store a password in general
n
Why? Password field is available by NetSuite.
b
take a look at the Table of Custom Field Type Descriptions for how to use a password field
n
But I am doing almost the same
I get the value by searching the employee record. It already gives me encrypted password value.
b
thats not what the help guide will tell you to do
it tells you to use the password field for display purposes only
and to encrypt it yourself
n
The password field gives the encrypted value when we load/search the record, right?
b
it might be, but netsuite doesnt share how its encrypted
you should encrypt it yourself
n
Oh... so what do you suggest?
b
and you should not use sha1
its not considered secure
more modern would be to use bcrypt, which is actually pretty slow in netsuite.
n
See the help page says the same: "When validating, you pull the encrypted password value into a hidden field and use custom code to encrypt the value the user typed and compare it with the actual encrypted value." I am pulling the encrypted password value (using search). and I am using custom code to encrypt the value the user typed in the Suitelet.
b
how do you
pull the encrypted password value into a hidden field
n
Instead of pulling it in hidden field, I am pulling in Suitelet using search.
b
thats literally what i am telling you not to do
and literally do what the help guide tells you to
n
Okay, so I will add the password into the hidden field on the Suitelet, right?
That's what you are saying, right?
b
custom field on the employee record
n
custom text field on employee record and not custom password field?
b
correct
n
Okay, i got your point. Take the plain text password and store it in another field after manually encrypting it. Then use the same encryption method on the value I am getting from Suitelet.
What if I need to use the custom password type field?
b
grab your third opinion then
i believe the password field is generally for display purposes only
n
Password field does not display any value.
b
as in you only use it because it obscures the input
n
password is encrypted and then saved in that field.
b
its encrypted in an unknown way, so its lost to you
n
got it. Thanks.