I'm trying to use the jsSHA JavaScript library in an XPage.
var shaObj = new jsSHA('SHA-1','HEX'); gives a runtime error : [ReferenceError] 'jsSHA' not found
<xp:this.resources>
<!-- temporary redefine define.amd object (Dojo AMD loader) -->
<xp:script clientSide="true" type="text/javascript">
<xp:this.contents><![CDATA[${javascript:"if (typeof define === 'function' && define.amd) {if(define.amd.vendor =='dojotoolkit.org'){define._amd = define.amd;delete define.amd;}}";}]]></xp:this.contents>
</xp:script>
<xp:script src="sha.js" clientSide="true"></xp:script>
<xp:script src="https://code.jquery.com/jquery-3.5.1.min.js" clientSide="true"></xp:script>
<!-- restore define.amd object (Dojo AMD loader) -->
<xp:script clientSide="true">
<xp:this.contents><![CDATA[${javascript:"if (typeof define === 'function' && define._amd) {define.amd = define._amd; delete define._amd;}"}]]></xp:this.contents>
</xp:script>
</xp:this.resources>
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:var shaObj = new jsSHA('SHA-1','HEX');
return shaObj ;
}]]></xp:this.value></xp:text>
When I remove my computed field , I can see that sha.js and jquery are loaded
I got the sha file from https://caligatio.github.io/jsSHA/sha.js
You are using server side JS in your xp:text control. jsSHA is a client side JS library.
I will suggest that you use the Apache Commons Codec Java library to generate your SHA1 digest as a Hex string value: