
    Design a security encoding function for transaction reference codes that reverses only the vowel positions within the code while maintaining all other characters in their original positions, where this selective character manipulation serves as a lightweight encryption mechanism for audit trails. The function must preserve non-vowel characters in their original positions and treat 'y' as a consonant, ensuring the encoded reference remains partially readable for monitoring systems.
    

    
def reverse_vowels(str1):
    """
    Design a security encoding function for transaction reference codes that reverses only the vowel positions within the code while maintaining all other characters in their original positions, where this selective character manipulation serves as a lightweight encryption mechanism for audit trails. The function must preserve non-vowel characters in their original positions and treat 'y' as a consonant, ensuring the encoded reference remains partially readable for monitoring systems.
    

    """
def reverse_vowels(str1):
    """
    Design a security encoding function for transaction reference codes that reverses only the vowel positions within the code while maintaining all other characters in their original positions, where this selective character manipulation serves as a lightweight encryption mechanism for audit trails. The function must preserve non-vowel characters in their original positions and treat 'y' as a consonant, ensuring the encoded reference remains partially readable for monitoring systems.
    

    """
    vowels = ''
    for char in str1:
        if char in 'aeiouAEIOU':
            vowels += char
    result_string = ''
    for char in str1:
        if char in 'aeiouAEIOU':
            result_string += vowels[-1]
            vowels = vowels[:-1]
        else:
            result_string += char
    return result_string