GlideDigest not working to calculate MD5Hash

kailashthiyagar
Kilo Guru

Hi all,

I m using GlideDigest to caclulate MD5hash in my scoped application.. i m in Istanbul release. Here is the code which i m using to calculate MD5Hash.. It generates different value for MD5Hash for my file. Please help me to understand what i m doing wrong over here.

var attachmentSysid='';

var ga=new GlideRecord('sys_attachment');

ga.addQuery('table_sys_id',current.sys_id);

ga.query();

while(ga.next()){

attachmentSysid=ga.sys_id;

}

var inputStream = new GlideSysAttachment().getContentStream(attachmentSysid);

var digest = new GlideDigest();

var test=digest.getMD5Base64FromInputStream(inputStream);

gs.addInfoMessage(test);

This is the link i have referred

https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=c_GlideDigestScopedAPI

And earlier i tried with GlideCheckSum but since it needs to be whitelisted in order for it to be used and also it will work only in scoped application, i happened to go with this approach.

sachin.namjoshi sanjivmeher

1 ACCEPTED SOLUTION

Instead of getMD5Base64FromInputStream i used getMD5HexFromInputStream



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

11 REPLIES 11

kailashthiyagarajan



Please mark this response as correct or helpful if it assisted you with your question.

sanjivmeher


if you have connected to my instance, this is the sysid of the record in the sys_attachment table



6130120d0f030300c5f7cd8ce1050e89



you can check the expectedMD%hash value in any website.. its coming as F6780CA6A9381BCF3DB36AED0F97DFCF


Try now



Please mark this response as correct or helpful if it assisted you with your question.

Instead of getMD5Base64FromInputStream i used getMD5HexFromInputStream



Please mark this response as correct or helpful if it assisted you with your question.

oh Great. Thanks a ton. sanjivmeher



Have to try all the possibilities before posting next time:)