There's no really an easy way as there's no direct single API for that.
The non-programmatic way is more or less like this:
$ sudo grep $USER /etc/shadow
This will spit out current user's shadow entry (note the sudo, this file is protected from non-root access by default), it should be in the form of:
<username>:$<hash method as an integer>$<salt>$<hashed password>:<ignore>
Now ask OpenSSL for help:
$ openssl passwd -<hash method as an integer> -salt <salt>
You will be prompted for password, input the user's password. The result should be the same as <hashed password> above.
Bypassing the sudo without compromising security is something I haven't found a way out for. OpenSSL hashing method might be convertible with something from fcl-hash, but I haven't tried finding yet.