- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 11:04 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 10:36 AM
Instead of getMD5Base64FromInputStream i used getMD5HexFromInputStream
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 02:36 PM
Hi Kailash,
Can you add the message marked in bold? Let me know what results you get for both the gs.addInfo
- 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;
- }
- gs.addInfoMessage('attachmentSysid is --------------'+attachmentSysid);
- var inputStream = new GlideSysAttachment().getContentStream(attachmentSysid);
- var digest = new GlideDigest();
- var test=digest.getMD5Base64FromInputStream(inputStream);
- gs.addInfoMessage(test);
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 06:55 PM
This is what i have observed.
attachmentSysid gives the sys id of the record in the "sys_attachment" table and it has the file which we attached.
I attached the file in one of the online site, it gives me the expected MD5 value. But through this method, i m getting different MD5Hash value..
If you would like to try it in my instance, here is the information
UserID : admin
Password :
Table : MD5Hash. And you can check the assoiciated BusinessRule for that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 08:57 AM
sanjivmeher any help?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 10:15 AM
Hi Kailash,
What is the expected MD5 value and for which file?
Please mark this response as correct or helpful if it assisted you with your question.