Created
February 3, 2022 20:11
-
-
Save JamoCA/e94b1100932db2c02b18eb11afc56079 to your computer and use it in GitHub Desktop.
Sample CFML to hash a string into an integer using java hashCode() using ColdFusion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 20220203 string.hashCode() returns an integer. | |
GIST: https://gist.github.com/JamoCA/e94b1100932db2c02b18eb11afc56079 | |
INFO: https://www.programiz.com/java-programming/library/string/hashcode | |
---> | |
<cfscript> | |
tests = [ | |
"hello world" | |
,now() | |
,"abcdefghijklmnopqrstuvwxyz" | |
,"ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
,123 | |
]; | |
results = createObject( "java", "java.util.Hashtable" ).init(); | |
for (test in tests) { | |
results["#test#"] = test.toString().hashCode(); | |
} | |
writedump(var=results, label="hashCode() results"); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment