Hi All,
We could use the Md5digest or any other digest type (like SHA1 or SHA512) as a function that returns it's characters as base64encoded or as hexadecimal numbers. Check this example script:
on mouseup
put "abc" into myContainer
put "MD5 encoded as Base64:" && MD5Var(myContainer,B) & cr into tVariable
put "MD5 as Hexadecimal numbers:" && MD5Var(myContainer) after tVariable
put tVariable
end mouseup
Function MD5Var tContainer tEncoding
-- This function returns an MD5 digest from a variable or container.
-- Because MD5 digest is binary data, we need to convert it
-- into Base64 or Hexadecimal numbers. For this conversion
-- we use the parameter named tEncoding with the value
-- B (for base64 encoding) or simply left tEncoding
-- empty and this function returns it's result as
-- Hexadecimal numbers
if tEncoding = B then
-- returns a string of 24 characters like
-- T+YY8ZhKxjGmYt0XMwDb9g==
return base64encode(md5digest(tContainer))
else -- by default, this function
-- returns a string of 32 characters like
-- 5EB63BBBE01EEED093CB22BB8F5ACDC3
put 0 into myVar
get binarydecode("H*",md5digest(tContainer),myVar)
return toupper(myVar)
end if
end MD5Var
Have a nice week!
Al
Converting MD5 digest
Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Return to “Getting Started with LiveCode - Complete Beginners”
Jump to
- LiveCode Community
- ↳ Announcements
- ↳ Developer Services Marketplace
- ↳ User Groups and Events
- ↳ SoCal LiveCode Group
- ↳ Greater Toronto Area LiveCode Users Group
- ↳ Off-Topic
- ↳ Made With LiveCode
- Getting Started With LiveCode
- ↳ Getting Started with LiveCode - Complete Beginners
- ↳ Getting Started with LiveCode - Experienced Developers
- ↳ Converting to LiveCode
- ↳ App Building Course
- ↳ Simple Messages
- ↳ Calculator
- ↳ Notes
- ↳ Clock
- ↳ Web Browser
- ↳ Weather
- ↳ Compass
- ↳ Photos
- Developing With LiveCode
- ↳ Talking LiveCode
- ↳ Databases
- ↳ Games
- ↳ Internet
- ↳ Multimedia
- ↳ Software Engineering
- ↳ Version Control
- ↳ Feature Proposals
- ↳ Bug Triage
- ↳ Legacy Project: MetaCard
- Extending LiveCode
- ↳ Using Plugins for Customizing the LiveCode IDE
- ↳ Using Externals
- ↳ Making IDE Plugins
- ↳ Building Externals
- ↳ LiveCode Builder
- Platform Specific
- ↳ Windows
- ↳ Mac OS
- ↳ Linux
- ↳ iOS Deployment
- ↳ Android Deployment
- ↳ CGIs and the Server
- ↳ HTML5
- ↳ Raspberry Pi
- Academic Endeavors
- ↳ Teaching with LiveCode
- ↳ Research and Post Secondary
- ↳ LiveCode University
- ↳ Educational Outreach
- Livecode Open Source Archived Forum- closed to posting
- ↳ Engine Contributors
- ↳ IDE Contributors
- ↳ Documentation and Tutorials
- ↳ Brainstorms
- ↳ Community Projects
- ↳ rIDE
- Third Party Extension Support
- ↳ Marketing Your Products
- ↳ Animation Engine
- ↳ chartsEngine
- ↳ MobGUI
- ↳ lcTaskList
- ↳ SQL Yoga
- ↳ MergEXT
- ↳ Data Grid Helper
- ↳ idea2app and Coding School
- ↳ Admin Archive
- LiveCode Hosting
- Forum Archives
- ↳ Archived: Third Party Extension Support
- ↳ rTree
- ↳ rGrid
- ↳ Data Tree
- ↳ Archived: LiveCode Open Source
- ↳ LiveCode Global Jam
- ↳ Testing Support
- ↳ Archived: Academic Endeavors
- ↳ September Academy
- ↳ Summer School 2013
- ↳ Archived: Project Specific
- ↳ Business and Kiosks
- ↳ Digital Art and Portfolios