
    Write a function that takes a transaction identifier string and creates a secure encoding by reversing only the vowels within it, while maintaining the positions of all consonants, to help mask sensitive transaction data in the fraud detection system. The encoding should consider 'y' as a consonant, and the original string length must remain unchanged.
    

    
def reverse_vowels(str1):
    """
    Write a function that takes a transaction identifier string and creates a secure encoding by reversing only the vowels within it, while maintaining the positions of all consonants, to help mask sensitive transaction data in the fraud detection system. The encoding should consider 'y' as a consonant, and the original string length must remain unchanged.
    

    """
def reverse_vowels(str1):
    """
    Write a function that takes a transaction identifier string and creates a secure encoding by reversing only the vowels within it, while maintaining the positions of all consonants, to help mask sensitive transaction data in the fraud detection system. The encoding should consider 'y' as a consonant, and the original string length must remain unchanged.
    

    """
    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