Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| vendors:cisco:uc:ucce:cvp [2025/03/12 15:17] – [Local value Examples] gerardorourke | vendors:cisco:uc:ucce:cvp [2025/10/17 17:00] (current) – gerardorourke | ||
|---|---|---|---|
| Line 35: | Line 35: | ||
| *[[vendors: | *[[vendors: | ||
| *[[https:// | *[[https:// | ||
| + | *[[vendors: | ||
| + | |||
| ==== CVP FTP ==== | ==== CVP FTP ==== | ||
| Line 85: | Line 87: | ||
| [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\VXMLServer\Parameters\Java\Options] | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\VXMLServer\Parameters\Java\Options] | ||
| - | ==== Local value Examples==== | + | ===== Set Value - Local Variables ===== |
| + | |||
| + | Create Local variables (similar to session variables) by using the JavaScript node " | ||
| + | |||
| + | ==== SHA 256 Example ==== | ||
| + | < | ||
| + | // CVP Rhino: SHA-256 via Java MessageDigest | ||
| + | function sha256_sql(accountNum) { | ||
| + | if (!accountNum) return null; | ||
| + | |||
| + | // Convert JS string to UTF-8 bytes | ||
| + | var javaStr = new java.lang.String(accountNum); | ||
| + | var bytes = javaStr.getBytes(" | ||
| + | |||
| + | // Create SHA-256 digest | ||
| + | var md = java.security.MessageDigest.getInstance(" | ||
| + | md.update(bytes); | ||
| + | var digest = md.digest(); | ||
| + | |||
| + | // Convert byte array to hex string | ||
| + | var hex = ''; | ||
| + | for (var i = 0; i < digest.length; | ||
| + | var h = (digest[i] & 0xFF).toString(16); | ||
| + | if (h.length === 1) h = ' | ||
| + | hex += h; | ||
| + | } | ||
| + | |||
| + | return hex.toUpperCase(); | ||
| + | } | ||
| + | |||
| + | // Example usage | ||
| + | var accountNum | ||
| + | var hash = sha256_sql(accountNum); | ||
| + | |||
| + | // Expected output: 9BBEF19476623CA56C17DA75FD57734DBF82530686043A6E491C6D71BEFE8F6E | ||
| + | </ | ||
| + | |||
| + | * Uses Java’s MessageDigest, | ||
| + | * Converts the string to UTF-8 bytes, matching SQL Server’s NVARCHAR behavior in HASHBYTES(' | ||
| + | * Outputs a hex string in uppercase, exactly like SQL Server’s CONVERT(VARCHAR(64), | ||
| + | |||
| + | CVP’s JavaScript engine (Rhino) runs on the JVM. That means every Java class is accessible from your JS code using the Packages namespace. Example: java.security.MessageDigest becomes Packages.java.security.MessageDigest in JS. | ||
| + | So in the above code, it is calling the Java MessageDigest.getInstance method to get a SHA-256 digest object. | ||
| - | Use Local vars (Set value) | + | You can instantiate objects, call methods, |
| ===Retrieving the Length of a Session Variable in Call Studio=== | ===Retrieving the Length of a Session Variable in Call Studio=== | ||