This is just a function I came up with in about 1 minute and thought I would share it with the community. It has no real practical use, so take it as something to learn from.
#include <Constants.au3>
MsgBox($MB_SYSTEMMODAl, '', CreateGUIDFromString('Some very simple string.'))
MsgBox($MB_SYSTEMMODAl, '', CreateGUIDFromString('A GUID string.'))
MsgBox($MB_SYSTEMMODAl, '', CreateGUIDFromString('1 chr'))
; #FUNCTION# ====================================================================================================================
; Name ..........: CreateGUIDFromString
; Description ...: Convert a string to a valid GUID.
; Syntax ........: CreateGUIDFromString($sString)
; Parameters ....: $sString - A string value of any length. Depending on the length of the string, this function may
; return with succeeding zeros to pad the GUID to a length of 32 characters.
; Return values .: Success - GUID string
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func CreateGUIDFromString($sString)
Local Const $CHR_COUNT = 1, $MAX_LENGTH = 32
Local $sGUID = ''
For $i = 1 To $MAX_LENGTH
$sGUID &= Hex(Asc(StringMid($sString, $i, $CHR_COUNT)), 2)
Next
Return StringRegExpReplace($sGUID, '([[:xdigit:]]{8})([[:xdigit:]]{4})([[:xdigit:]]{4})([[:xdigit:]]{4})([[:xdigit:]]{12})(?:[[:xdigit:]]{0,})', '\{\1-\2-\3-\4-\5\}')
EndFunc ;==>CreateGUIDFromString