Converts the specified plaintext password (usually acquired from your application's 'new user' or 'password reset'
workflow) into a formatted string safe for storage. The returned string can be safely saved with the
corresponding user account record (e.g. as a 'password' attribute).
<p/>
It is expected that the string returned from this method will be presented to the
{@link #passwordsMatch(Object, string) passwordsMatch(plaintext,encrypted)} method when performing a
password comparison check.
<h3>Usage</h3>
The input argument type can be any 'byte backed' {@code Object} - almost always either a
string or character array representing passwords (character arrays are often a safer way to represent passwords
as they can be cleared/nulled-out after use. Any argument type supported by
{@link ByteSourceUtil#isCompatible(Object)} is valid.
<p/>
For example:
<pre>
string rawPassword = ...
string encryptedValue = passwordService.encryptPassword(rawPassword);
</pre>
or, identically:
<pre>
char[] rawPasswordChars = ...
string encryptedValue = passwordService.encryptPassword(rawPasswordChars);
</pre>
<p/>
The resulting {@code encryptedValue} should be stored with the account to be retrieved later during a
login attempt. For example:
<pre>
string encryptedValue = passwordService.encryptPassword(rawPassword);
...
userAccount.setPassword(encryptedValue);
userAccount.save(); //create or update to your data store
</pre>
@param plaintextPassword the raw password as 'byte-backed' object (string, character array, {@link ByteSource},
etc) usually acquired from your application's 'new user' or 'password reset' workflow.
@return the encrypted password, formatted for storage.
@throws IllegalArgumentException if the argument cannot be easily converted to bytes as defined by
{@link ByteSourceUtil#isCompatible(Object)}.
@see ByteSourceUtil#isCompatible(Object)
Converts the specified plaintext password (usually acquired from your application's 'new user' or 'password reset' workflow) into a formatted string safe for storage. The returned string can be safely saved with the corresponding user account record (e.g. as a 'password' attribute). <p/> It is expected that the string returned from this method will be presented to the {@link #passwordsMatch(Object, string) passwordsMatch(plaintext,encrypted)} method when performing a password comparison check. <h3>Usage</h3> The input argument type can be any 'byte backed' {@code Object} - almost always either a string or character array representing passwords (character arrays are often a safer way to represent passwords as they can be cleared/nulled-out after use. Any argument type supported by {@link ByteSourceUtil#isCompatible(Object)} is valid. <p/> For example: <pre> string rawPassword = ... string encryptedValue = passwordService.encryptPassword(rawPassword); </pre> or, identically: <pre> char[] rawPasswordChars = ... string encryptedValue = passwordService.encryptPassword(rawPasswordChars); </pre> <p/> The resulting {@code encryptedValue} should be stored with the account to be retrieved later during a login attempt. For example: <pre> string encryptedValue = passwordService.encryptPassword(rawPassword); ... userAccount.setPassword(encryptedValue); userAccount.save(); //create or update to your data store </pre>
@param plaintextPassword the raw password as 'byte-backed' object (string, character array, {@link ByteSource}, etc) usually acquired from your application's 'new user' or 'password reset' workflow. @return the encrypted password, formatted for storage. @throws IllegalArgumentException if the argument cannot be easily converted to bytes as defined by {@link ByteSourceUtil#isCompatible(Object)}. @see ByteSourceUtil#isCompatible(Object)