package set1 func XORHexString(content, password string) string { var hexValues = map[byte]byte{ '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15, } var hexRepresentations = []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'} contentBytes := []byte(content) passwordBytes := []byte(password) buffer := make([]byte, len(contentBytes), len(contentBytes)) for i := 0; i < len(contentBytes); i++ { contentByte := hexValues[contentBytes[i]] passwordByte := hexValues[passwordBytes[i]] buffer[i] = hexRepresentations[contentByte^passwordByte] } return string(buffer) }