cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Issue of type password field in datashape making problem On import

MA8731174
14-Alexandrite

Issue of type password field in datashape making problem On import

Hello Community,

     I  have datatable with usercredentials stored in it and one of the field is of password type which i do hash also before saving it. Now the issue is when i import this datatable from thingworx 9.1 to 9.3 and in my code below:= i am unable to get the value from datatable it just does not appear EntryExists.row[0].loginPassword is undefined even though on old thingworx version everything is working fine.

 

 

 let EntryExists = Things[userDataTable].GetDataTableEntryByKey({ key: hashedLoginName });
    if(EntryExists && EntryExists.rows[0].hashedLoginName == hashedLoginName && EntryExists.rows[0].loginPassword == hashedLoginPassword){

 

 

I have changed nothing but still it just does not work because its not getting it from datatable but on other hand all the fields are showing values. Why its like that 

 

 

Jamal8548_0-1724404186317.png

 

My assumption: I think its not possible to import the userpassword which are hashed into another datatable and if i change the password field to string and then import the datatable still it shows the different hashed values and my service does not work on new server.....

13 REPLIES 13
javed_a
12-Amethyst
(To:MA8731174)

Have you tried Universal Export, with Binary or XML, for entities not data?

Regards,
Javed Akhtar
MA8731174
14-Alexandrite
(To:javed_a)

how can i export a datatable with binary or XML any idea? Its a datatable actually and i can only import it as data.

javed_a
12-Amethyst
(To:MA8731174)

I mean while exporting data table entity select universal export, and Export data as usual.

Also make sure whatever hashing key (mechanism I am guessing) you are using that is already present on target server.

javed_a_0-1724410204514.png

 

Regards,
Javed Akhtar
MA8731174
14-Alexandrite
(To:javed_a)

this is the error on import which is coming

 

Jamal8548_0-1724411463706.png

 

Jamal8548_1-1724411529450.png

 

 

javed_a
12-Amethyst
(To:MA8731174)

Please use file storage to export the data, then copy that data in file storage of target server, and import using Source Control Entities (or File storage). Refer the documentation below:

Importing and Exporting Data, Entities, and Extensions (ptc.com)

Regards,
Javed Akhtar
MA8731174
14-Alexandrite
(To:MA8731174)

oh i have choosen import type entity and now import is done but now i cannot see any data entries in this datatable. should i do now import for data ??

javed_a
12-Amethyst
(To:MA8731174)

There are two steps.

1.  Export data table entity, it will have only structure/definition but not data.

2. To export data, you need to export it separately as said above.

Regards,
Javed Akhtar
MA8731174
14-Alexandrite
(To:javed_a)

i have followed these both steps still not working should i try now with xml?

javed_a
12-Amethyst
(To:MA8731174)

Please follow below steps to export and import data (Provided data table entity is already there), make sure required folder are there inside repository

javed_a_0-1724412895875.png

javed_a_1-1724412950509.png

 

 

Regards,
Javed Akhtar
MA8731174
14-Alexandrite
(To:javed_a)

thanks for your info but still the field loginPAssword is empty it just does not take the value of this field in datatable all the entries have no value for this field because it is of type password may be thats why.

if i change it to string and do then import then the values come but then my system still does not work.

javed_a
12-Amethyst
(To:MA8731174)

Once value is there in system as a string, you might write service to hash again and update the values.

Regards,
Javed Akhtar
javed_a
12-Amethyst
(To:javed_a)

Also please check article below this is relevant to your case:

Password Base type (ptc.com)

Regards,
Javed Akhtar
MA8731174
14-Alexandrite
(To:javed_a)

So, here it is a way.. I am doing ..first hashing of the password and secondly the baseType of field password is also password so it get again somehow hashed from the system. As per documentation they recommended to do like this ===> Resources["EncryptionServices"].EncryptPropertyValue(params) 

 

I dont think so that there is any way to import these passwords then from datatable.

 

 

 

result.AddRow({
	loginName: loginName.toUpperCase(),
	firstName: firstName,
	lastName: lastName,
	language: language,
	emailAddress: emailAddress.toLowerCase(),
	hashedLoginName: me.SHA256({
		toHash: loginName.toUpperCase()
	}),
	groups: groups,
	loginPassword: Resources["EncryptionServices"].EncryptPropertyValue({
		data: me.SHA256({
			toHash: loginPassword
		})
	})
});
//me.UserDataBase
Things[userDataTable].AddDataTableEntry({	values: result });

 

 

 

info: There is a difference between hashing and encryption. SHA256 is a hashing function not an encryption function.
Since SHA256 is not an encryption function, it cannot be decrypted. What you probably want is reversing hashed value to normal text.
SHA256 cannot be reversed because it’s a one-way function it is not designed to be used that way 

that’s the idea behind hashing - so that if somebody has your data they cannot “read it”.

Announcements


Top Tags