Let R be a unital ring with involution, we give the characterizations and representations of the core and dual core inverses of an element in R by Hermitian elements (or projections) and units. For example, let a in R and n is an integer greater than or equal to 1, then a is core invertible if and only if there exists a Hermitian element (or a projection) p such that pa=0, a^n+p is invertible. As a consequence, a is an EP element if and only if there exists a Hermitian element (or a projection) p such that pa=ap=0, a^n+p is invertible. We also get a new characterization for both core invertible and dual core invertible of a regular element by units, and their expressions are shown. In particular, we prove that for n is an integer greater than or equal to 2, a is both Moore-Penrose invertible and group invertible if and only if (a*)^n is invertible along a.